diff --git a/uart.c b/uart.c index 7f5f144..a2f7788 100644 --- a/uart.c +++ b/uart.c @@ -7,9 +7,9 @@ #include void initUART() { - // Set baud rate - UBRR0H = (uint8_t)(F_CPU / (BAUD * 16UL) - 1) >> 8; - UBRR0L = (uint8_t)(F_CPU / (BAUD * 16UL) - 1); + // Set baud rate with precalculated values (see setbaud.h) + UBRR0H = UBRRH_VALUE; + UBRR0L = UBRRL_VALUE; // Enable receiver and transmitter UCSR0B |= (1 << RXEN0) | (1 << TXEN0); // Set frame format: 8 data, 1 stop bit