Utilizing setbaud
This commit is contained in:
parent
241536a6e9
commit
bb69b840cf
1 changed files with 3 additions and 3 deletions
6
uart.c
6
uart.c
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue