/* * $Id: simpleuart.c,v 1.1 2002/10/13 03:02:28 ken Exp $ * very simple test program to assure that uart works * this just echoes characters back out the uart interface * */ #include #include char recchar(void) { while (! (UCSRA & _BV(RXC))); return UDR; } void sendchar(char c) { while (! (UCSRA & _BV(TXC))); UDR = c; } int main(int argc, char ** argv) { volatile int c; /* setup serial */ UBRR = 51; /* 9600 at 8 mhz */ UCSRB |= (_BV(RXEN) | _BV(TXEN)); sendchar('F'); sendchar('\n'); while(1){ c = recchar(); /* right back at 'cha */ sendchar(c); }; return(0); } /* END MAIN */ /* EOF */