Debian Codegraph @

examples/echo-direct.c

raw symbols SCIP
1 #include <avr/io.h>
2
3 int main(void)
4 {
5 uint8_t data;
6
7 DDRB = 255;
8 UCSRB = (1 << RXEN) | (1 << TXEN);
9 UBRRH = 0; ////38400 baudrate, 8 databit, 1 stopbit, No parity
10 UBRRL = 12; // At 8MHz (12 =>38400)
11 UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<< UCSZ0);
12
13 for(;;)
14 {
15 while ( !(UCSRA & (1<<RXC)) ); //wait on Rx
16 data = UDR; // read a byte
17 PORTB = data;
18 while ( !(UCSRA & (1<<UDRE)) ); // Rx Empty ?
19 UDR = data + 1;
20 }
21 }