Utilizing setbaud

This commit is contained in:
Imbus 2024-03-23 21:33:16 +01:00
parent 241536a6e9
commit bb69b840cf

6
uart.c
View file

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