cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L452 SystemClock_Config with STM32CubeMX

Mateusz Kaskow
Associate II
Posted on April 03, 2018 at 12:27

Hi,

I have Nuckeo-L452RE with STM32L452RE uC on board.

This uC max speed is 80MHz.

But after enabling MCO on pin PA8 in STM32CubeMX and generating the code to Atollic, I could see wrong SYSCLK frequencies.

The reason of this behavior is CubeMX generates wrong content of SystemClock_Config function:

/**Initializes the CPU, AHB and APB busses clocks

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.HSICalibrationValue = 16;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;

RCC_OscInitStruct.PLL.PLLN = 20;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;

RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;

RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;

//...

It works fine after changing it to:

/**Initializes the CPU, AHB and APB busses clocks

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.HSICalibrationValue = 64;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;

RCC_OscInitStruct.PLL.PLLM = 1;

RCC_OscInitStruct.PLL.PLLN = 20;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;

RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;

RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;

Best regards,

Mateusz

#tipsandtricks
2 REPLIES 2
Imen.D
ST Employee
Posted on April 04, 2018 at 15:56

Hello

Kaskow.Mateusz

,

We confirmthe missing of

PLLM parameter

in the generation

content ofSystemClock_Config functionfor STM32L4 us

ing

CubeMX

version 4.25

.

T

hisCubeMX bug passed internally to CubeMx team for fix in the coming release.

Sorry for such inconvenience that it may bring.

Best Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on April 05, 2018 at 07:44

Thanks for confirmation.

I'm moving from SPL library to Cube and learning it, so it took me a while to figure that it is CubeMX issue.

But on the other hand it is nice, that this forum is living and helpful.

Best regards,

Mateusz