#include <avr/io.h>
//void swap (int *px, int *py);
void swap (char *px, char *py)
{
char temp;
temp = *px;
*px = *py;
*py = temp;
}
void reversal (char a[ ], char n)
{
char i, j, k;
j = n%2;
// n is the number of elements in the array
if (j == 1)
k = n + 1;
for (i = 0; i < (k)/2 ; i++)
{
swap (&a[i], &a[n - i - 1]);
}
/*for (i = 0; i < n ; i++)
{
printf("%d \n",a[i] );
}*/
}
int main(void)
{
/* Replace with your application code */
char n = 5;
char a[5] = {1, 2, 3, 4, 5};
//reversal(a, n);
}
Hi. I am using ATxmega128A1 to initialize the project and then I am using the Simulator tool as the debugger.What AVR are you using ? The "recipe" error might refer to the
compiler not having the recipe for compiling for the chip you are using.
It may make a difference whether the source file is *.c or *.cpp.
Yes, you are right but the code works in other C ide with int instead of char. so that isnt the problem.k isn't initialized for even n values. For odd n values, the code superfluously swaps the center element with itself.
Thankyou. But I am still not able to fix my error. my assembly files work okay. which version of avr studio are you using?I compiled your code as a .c file in AVR Studio with the project using ATxmega128A1 with GCC, and it completed successfully, with 4 warnings, no errors.
Also can please send me the warnings.Thankyou. But I am still not able to fix my error. my assembly files work okay. which version of avr studio are you using?
and do you have a header file of the controller in the dependencies.Thankyou. But I am still not able to fix my error. my assembly files work okay. which version of avr studio are you using?
--- Updated ---
Also can please send me the warnings.
I get the same error even with just avr/io.h and just main() function. Now I get recipe for target main.o failed.Thankyou. But I am still not able to fix my error. my assembly files work okay. which version of avr studio are you using?
--- Updated ---
Also can please send me the warnings.
--- Updated ---
and do you have a header file of the controller in the dependencies.
This is what I expected from you...Also can please send me the warnings.
XC8 with MPLab X will compile for AVRHi. I would like to know if there is any other software to compile C programs for AVR microcontrollers other than AVR studio. Does MPLAB ide provide compilation of C programs forAVR microcontroller
Hi. I kind of figured it out. First we turn off windows defender and finally from Debug option we select Options and once there we select the appropriate Toolchain on the right hand of the pop up window. (It may be necessary to disable the antivirus also.)
For the life of me I cannot understand the connection between windows defender and Microchip or Atmel Studio. The Assembler in Simulator mode works with Windows Defender on.
However I am still unable to print the result in The Output, for example, the maximum array.
If you can help with this.
yes. you are right and it is very complicated. I have tried with USART and not succeeded. thanks. I will keep trying.Using printf() with an AVR is complicated. Do a google search for more information on how to do it. Usually, output uses the USART on the AVR through a Serial interface to a terminal, such as a TTL to USB converter. Or, to a display such as a 16x2 LCD attached to the AVR.
C:
UCSR0A |= (1 << U2X0); // U2X0 = 1 = set double speed mode
UCSR0B = (1 << RXEN0) | (1 << TXEN0); // enable transmit, receive
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); // Use 8-bit character sizes
UBRR0 = 16; // load 115200 baud value into the UBRR0 register
//---------------------------------------------------------------------------------------
to send a byte:
UDR0 = a[i];
a[i] may need to have 0x30 added to it to print as the ascii character for a number on the terminal
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?