From bb69b840cfd7b718a93aa70ff9f42eb878f5e14f Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sat, 23 Mar 2024 21:33:16 +0100 Subject: [PATCH] Utilizing setbaud --- uart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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