STM32: USARTv1: improve baud rate calculation accuracity
This commit is contained in:
parent
a173d119f1
commit
adeb3c34cf
|
@ -108,9 +108,9 @@ static void usart_init(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
#else
|
#else
|
||||||
if (sdp->usart == USART1)
|
if (sdp->usart == USART1)
|
||||||
#endif
|
#endif
|
||||||
fck = STM32_PCLK2 / config->speed;
|
fck = (STM32_PCLK2 + config->speed / 2) / config->speed;
|
||||||
else
|
else
|
||||||
fck = STM32_PCLK1 / config->speed;
|
fck = (STM32_PCLK1 + config->speed / 2) / config->speed;
|
||||||
|
|
||||||
/* Correcting USARTDIV when oversampling by 8 instead of 16.
|
/* Correcting USARTDIV when oversampling by 8 instead of 16.
|
||||||
Fraction is still 4 bits wide, but only lower 3 bits used.
|
Fraction is still 4 bits wide, but only lower 3 bits used.
|
||||||
|
|
Loading…
Reference in New Issue