Professional Documents
Culture Documents
AVR Program For Serial Interface
AVR Program For Serial Interface
Serial.C
Simple program that first initializes the serial port for 9600, N, 8, 1.
Second, the program initializes PortC for output to the LEDs.
Third, the program enters an endless loop that...
Uses the standard library function to get a serial character
Display the character on the LEDs
Echo the character back to the sending device
*/
main()
{
unsigned char ch; // 8 bit variable to store the serial character
unsigned int UBR; // 16 bit variable to hold serial port calculations
while(1) // do forever...
{
ch = getchar(); // get a character from the serial port
PORTC = ~ch; // display the character on the LEDs
putchar(ch); // send the character back to the terminal
}
}