Skip to main content
Mateusz Kaskow
Associate II
April 3, 2018
Question

STM32L452 SystemClock_Config with STM32CubeMX

  • April 3, 2018
  • 1 reply
  • 690 views
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
    This topic has been closed for replies.

    1 reply

    ST Technical Moderator
    April 4, 2018
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Mateusz Kaskow
    Associate II
    April 5, 2018
    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