File: echo-direct.c

package info (click to toggle)
kuttypy 2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,896 kB
  • sloc: python: 58,651; javascript: 14,686; xml: 5,767; ansic: 2,716; makefile: 453; asm: 254; sh: 48
file content (21 lines) | stat: -rw-r--r-- 498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <avr/io.h>

int main(void)
{
  uint8_t data;

  DDRB = 255;
  UCSRB = (1 << RXEN) | (1 << TXEN);
  UBRRH = 0;             ////38400 baudrate, 8 databit, 1 stopbit, No parity
  UBRRL = 12;            // At 8MHz (12 =>38400)
  UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<< UCSZ0); 

  for(;;)
     {
     while ( !(UCSRA & (1<<RXC)) );  //wait on Rx
     data = UDR;                     // read a byte
     PORTB = data;
     while ( !(UCSRA & (1<<UDRE)) ); // Rx Empty ?
     UDR = data + 1;
  }
}