Skip to content

Commit 5f0ed2d

Browse files
committed
drivers/serial: stm32: Force oversampling value
When setting baudrate register, baudrate value is computed according to the oversampling given value, which is default boot time value (16). In case oversampling value has been changed by bootloader (as in case of TFM bootloader), a desynchronsation happens between OVR and BRR values and the ouptut baudarate is incorrect. For oversampling register before setting the baudrate to avoid this situation. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 4ba3878 commit 5f0ed2d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/serial/uart_stm32.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ static inline void uart_stm32_set_baudrate(const struct device *dev,
7575
baud_rate);
7676
} else {
7777
#endif /* HAS_LPUART_1 */
78-
78+
#ifdef USART_CR1_OVER8
79+
LL_USART_SetOverSampling(UartInstance,
80+
LL_USART_OVERSAMPLING_16);
81+
#endif
7982
LL_USART_SetBaudRate(UartInstance,
8083
clock_rate,
8184
#ifdef USART_PRESC_PRESCALER

0 commit comments

Comments
 (0)