cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX V5.3.0 does not generate correct code for SystemClock_Config()

DBroo.1
Associate III

Anyone aware of this problem and any workaround, other than manually changing the generated file? Specifically, ​ RCC_OscInitStruct.PLL.PLLR,  RCC_OscInitStruct.PLL.PLLP and

 RCC_OscInitStruct.PLL.PLLR are not being configured correctly, causing the first call to HAL_GetTick() inside HAL_RCC_OscConfig() to crash.

3 REPLIES 3

For what STM32 part? Trying to narrow this down a bit.

Make sure SystemClock_Config() zeros out the local/auto variable.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DBroo.1
Associate III

​Sorry Clive. It's the STM32G070CB. And to be more specific, these parameters were configured on the Clock Configuration Tab in Cube as:

RCC_OscInitStruct.PLL.PLLN = 9

RCC_OscInitStruct.PLL.PLLP = 3

RCC_OscInitStruct.PLL.PLLR  = 3,

but the code generated:

RCC_OscInitStruct.PLL.PLLN = 8

RCC_OscInitStruct.PLL.PLLP = 2

RCC_OscInitStruct.PLL.PLLR = 2.

HOWEVER, in trying to pull this information together for you this morning, Cube generated the correct code this time. ??? I have been quite careful to save the project before generating code, but "Generate Code" saves the project anyway. So, I am not sure what is going on.

DBroo.1
Associate III

​Resolved