cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong BRR calculated by STM32CubeMx for STM32L053

jephua
Associate II
Posted on October 17, 2014 at 09:36

I am using the STM32CubeMx version 4.3.1 and inside the clock configuration page, the PCLK2 is used for USART1CLK. It shows 2.097.

However, in HAL_RCC_GetPCLK2Freq function, the return value was 2.000.

This caused problem with the uart transmitting data, please help to check if there is a bug. I am using the STM32L053 discovery board fyi.

Currently the workaround is to manually calculate the BRR and set it after I call the HAL_UART_MspInit.

#stm32l053
2 REPLIES 2
stm32cube-t
Senior III
Posted on November 19, 2014 at 15:30

Dear user,

This is an L0 HAL driver issue. In hal_rcc.c we have the following table:

const uint32_t MSIRangeTable[7] = {64000, 128000, 256000, 512000, 1000000, 2000000, 4000000};

Next firmware release will provide the solution: the MSI range table has been removed and replaced with a calculation algorithm.

Best Regards

johan2
Associate II
Posted on November 25, 2014 at 18:59

When I saw this problem I modified line97 in stm32l0xx_hal_rcc.c to

const uint32_t MSIRangeTable[7] = {65536, 131072, 262144, 524288, 1048000, 2097000, 4194000};

Note that this was with version 1.0.0 in cube.