diff --git a/os/hal/ports/STM32/LLD/USARTv1/hal_serial_lld.c b/os/hal/ports/STM32/LLD/USARTv1/hal_serial_lld.c index 65697703a..68e707edd 100644 --- a/os/hal/ports/STM32/LLD/USARTv1/hal_serial_lld.c +++ b/os/hal/ports/STM32/LLD/USARTv1/hal_serial_lld.c @@ -108,9 +108,9 @@ static void usart_init(SerialDriver *sdp, const SerialConfig *config) { #else if (sdp->usart == USART1) #endif - fck = STM32_PCLK2 / config->speed; + fck = (STM32_PCLK2 + config->speed / 2) / config->speed; else - fck = STM32_PCLK1 / config->speed; + fck = (STM32_PCLK1 + config->speed / 2) / config->speed; /* Correcting USARTDIV when oversampling by 8 instead of 16. Fraction is still 4 bits wide, but only lower 3 bits used.