AnsweredAssumed Answered

STM32L0 UART HAL driver issue

Question asked by jon.gordon on Nov 11, 2015
Latest reply on Nov 12, 2015 by Amel N
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 19200.

Has this been raised before?  Note: this is with the latest IAR compiler for ARM (7.50.1)

Outcomes