cpu/sam0_common: uart: fix baud rate calculation
In fractional mode, 3 bits are used to store the fractional part. Therefore we must multiply / divide by 8 instead of 10 in order to get the correct values.
This commit is contained in:
parent
736e5e5a35
commit
7e5aa7e775
@ -89,9 +89,9 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
||||
}
|
||||
|
||||
/* calculate and set baudrate */
|
||||
uint32_t baud = ((((uint32_t)CLOCK_CORECLOCK * 10) / baudrate) / 16);
|
||||
dev(uart)->BAUD.FRAC.FP = (baud % 10);
|
||||
dev(uart)->BAUD.FRAC.BAUD = (baud / 10);
|
||||
uint32_t baud = ((((uint32_t)CLOCK_CORECLOCK * 8) / baudrate) / 16);
|
||||
dev(uart)->BAUD.FRAC.FP = (baud % 8);
|
||||
dev(uart)->BAUD.FRAC.BAUD = (baud / 8);
|
||||
|
||||
/* enable transmitter, and configure 8N1 mode */
|
||||
dev(uart)->CTRLB.reg = SERCOM_USART_CTRLB_TXEN;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user