cancel
Showing results for 
Search instead for 
Did you mean: 

UART information missing from RefMan, HAL_UART_Init() error

gbm
Lead III

I found this problem with STM32L476 but I suspect it may be a general STM32 quirk.
The manual does not list the minimum and maximum value of UART BRR register. While the minimum value of 0x10 seems to be quite obvious, the maximum correct value in the default 16 x oversampling seems to be 0xFFF7. The UART doesn’t work with any bigger value.
The HAL_UART_Init() calls UART_SetConfig(), containing the check for BRR value rage using constants defined in stm32l4xx_hal_uart.c. The UART_BRR_MAX value is wrong, thus HAL may configure the UART incorrectly.

I discovered this while trying to configure L4 UART running at 80 MHz for 1200 baud. The minimum possible speed at 80 MHz is 1222 baud, which is within the allowed error limit, but to set the speed 0xFFF7 value must be used instead of the intuitively maximum value of 0xFFFF.
This is slightly related to my old topic on RefMan problems related to UARTs:
https://stcommunity.st.com/t5/stm32-mcu-products/errors-in-uart-baud-rate-sections-of-reference-manuals/td-p/62095

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
0 REPLIES 0