2015-11-11 01:11 PM
Hi,
I have spotted a potential bug in the HAL driver for the UART on (at least) the STM32L0. The macro for determining the BRR register value__DIV_LPUART is defined as follows:#define __DIV_LPUART(_PCLK_, _BAUD_) (((_PCLK_)*256)/((_BAUD_)))
Any value passed to this macro for the _PCLK_ token over 16MHz will result in overflow as it is multiplied by 256 before being divided by the required _BAUD_.
I noticed this as I tried to use the HAL driver to set my PCLK driven UART (32MHz) to 9600 and saw it come out as 19
Has this been raised before? Note: this is with the latest IAR compiler for ARM (7.1)
#hal #uart #cubemx #stm32l0
2015-11-12 01:00 AM
Hijon.gordon,
Please use the last STM32CubeL0 version (1.3.0). This bug is already fixed there:#define __DIV_LPUART(_PCLK_, _BAUD_) ((uint32_t) (((((uint64_t)_PCLK_)*0))/(((uint64_t)_BAUD_))))
-Mayla-
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.