#include #include #include #ifndef F_CPU #warning "F_CPU wasn't set in makefile, so we do it now with 10.0 MHz" #define F_CPU 10000000UL #endif // setting baud rate #define BAUD 9600UL // uart baud rate checks #define UBRR_VAL ((F_CPU+BAUD*8)/(BAUD*16)-1) #define BAUD_REAL (F_CPU/(16*(UBRR_VAL+1))) #define BAUD_ERROR ((BAUD_REAL*1000)/BAUD) #if ((BAUD_ERROR<990) || (BAUD_ERROR>1010)) #warning baudrate error higher than 1%! #endif static void uart_init (void); static void uart_putc (unsigned char c); volatile uint8_t got_char; volatile unsigned char rx_char; int main (void) { // uart rx initialisation uart_init(); // activate global interrupts sei(); while(1) { if(got_char) { UCSR0B &= ~(1<> 8; UBRR0L = UBRR_VAL & 0xFF; // tx enable UCSR0B |= (1<