cancel
Showing results for 
Search instead for 
Did you mean: 

BUG in STM32CubeMX generated code (SystemClock_Config for STM32F105/107)

Serge GW
Associate II
Posted on April 05, 2017 at 15:38

STM32CubeMX generated code for STM32F105xC/STM32F107xC inside SystemClock_Config() function never calls 

SystemCoreClockUpdate().

Part&sharp1: This bug appears when external crystal resonator in use and HSE_VALUE not equal to 8 MHz, so the system producing code that does not contain SystemCoreClockUpdate(), so this function must be called just after HAL_RCC_ClockConfig() in main.c

Part&sharp2: 

SystemCoreClockUpdate() finction in 

system_stm32f1xx.c uses uint32_t for pllmull multiplier value, but when multiplier coefficient of 6.5 - is used, this 

pllmull can't keep fractional number of 13/2, so additional variable is needed or changing pllmul to float. Solution to use fractional number as two intergers - is in attachment.

By using this changes, SysTick does it's job exactly as expected.

#stm32f107xc #stm32f105xc #systick #systemclock_config #bug
3 REPLIES 3
Serge GW
Associate II
Posted on April 05, 2017 at 16:07

Also inside SystemClock_Config() there is structure initialisation that looks like:

RCC_OscInitStruct.OscillatorType =

RCC_OSCILLATORTYPE_HSI | 

RCC_OSCILLATORTYPE_HSE;

Which is not ok and HAL_RCC_OscConfig() never returns HAL_OK.

That variable must set just one value, but not both.

Systems been used:

STM32CubeMX version 4.20.0

and STM32CubeF1 Firmware Package V1.4.0

Imen.D
ST Employee
Posted on April 05, 2017 at 17:33

Hello,

1- The issue on the RCC config is fixed in the new patch releases CubeMx 4.20.1.

So, please download and update the new version 4.20.1 to resolve this issue.

PS:  if you are using an old .ioc project, you should first EDIT the .ioc file and REMOVE this line (remove the RCC.OscillatorType that you don't need)

RCC.OscillatorTypeHSI=RCC_OSCILLATORTYPE_HSI

Then re-generate the project, this will resolve your problem.

Please keep me informed about your updates.

2- About PLLMUL 

multiplier, 

 the issue is on the aPLLMULFactorTable, inside STM32CubeF1 V1.4.0 (stm32f1xx_hal_rcc.c and stm32f1xx_hal_rcc_ex.c) which should be :

const uint8_t aPLLMULFactorTable[14] = {0, 0, 4, 5, 6, 7, 8, 9, 0, 0, 0,

0, 0,

13};

instead

const uint8_t aPLLMULFactorTable[12] = {0, 0, 4, 5, 6, 7, 8, 9, 0, 0, 0, 13};

This issue is already reported internally and will be fixed in the coming version.

Thanks

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Serge GW
Associate II
Posted on April 05, 2017 at 17:51

Hi,

Just installed  

STM32CubeMX version 4.20.1 and generated project again.

Good news: 

Yes, now 

RCC_OscInitStruct.OscillatorType - is setted correctly

Bad news: unfortuinaly the main topic's bugs - are still presented: 

SystemCoreClockUpdate() is not called after configured clocks and it's 

pllmull variable is still uint32_t that is not able to keep fractional number of 6.5x multiplier.