cancel
Showing results for 
Search instead for 
Did you mean: 

[bug report] STM32CubeMX RCC initialization on STM32L4x misses PLLM and triggers assert error

motla
Associate II
Posted on March 20, 2018 at 15:18

On STM32L476RETx

void SystemClock_Config(void){

    RCC_OscInitTypeDef RCC_OscInitStruct;

    RCC_ClkInitTypeDef RCC_ClkInitStruct;

    RCC_PeriphCLKInitTypeDef PeriphClkInit;

    // ...

    

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|

        RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;

    

RCC_OscInitStruct.LSEState = RCC_LSE_ON;

    

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

    

RCC_OscInitStruct.HSICalibrationValue = 16;

    

RCC_OscInitStruct.MSIState = RCC_MSI_ON;

    

RCC_OscInitStruct.MSICalibrationValue = 0;

    

RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11;

    

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

    

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;

    // NO RCC_OscInitStruct.PLL.PLLM initialization !

 

    // should be = 1 but is = 0 by default so it triggers assert_failed and _Error_Handler

    

RCC_OscInitStruct.PLL.PLLN = 10;

    

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;

    

RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;

    

RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;

    

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

    

{

    

_Error_Handler(__FILE__, __LINE__);

    

}

}

Thanks

Romain

1 ACCEPTED SOLUTION

Accepted Solutions
Houda GHABRI
ST Employee
Posted on May 10, 2018 at 18:45

Hi

Lamothe.Romain

,

CubeMX version 4.1

(in which thisissue is resolved) isavailable now on ST Website.

Regards,

Houda

View solution in original post

9 REPLIES 9
Kolos Károly
Associate
Posted on March 22, 2018 at 17:18

Approved, I have the same issue (CubeMX 4.25.0).

john doe
Lead
Posted on March 23, 2018 at 01:19

And if you dont use full assert, and build it, your system core clock speed starts at half speed, then goes down each time you hit the reset button.  Got it as low as 11mhz, from 40. When it should have been 80.

Posted on March 23, 2018 at 01:42

Would also strongly recommend the use of the RCC_OscInitTypeDef RCC_OscInitStruct = {0}; form to ensure that the auto/local variable actually gets initialized to something predictable, normal behaviour exposes random stack content.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
roman239955
Associate III
Posted on April 03, 2018 at 20:19

This issue is a CubeMX problem.

4.24 produces the correct RCC PLLM

4.25 does not.

I posted something to tech support a while back on a previous version, maybe 4.22, that does not produce RCC PLLM in the main.c initialization when you are using the PLL as a system clock.  I use MSI to PLL for my system clock.

4.23 produces RCC PLLM and I think 4.21.1 does as well.

I don't advise using this as a work around but rather a test.  IF you go into the .ioc file and change

MxDb.Version=DB.4.0.250

to

MxDb.Version=DB.4.0.240

then the PLLM initialization will come back.

I generated 3 projects using the same source for import to verify that PLLM is generated using 4.24 and 4.23.

According to the CubeMX change log there were a lot of changes when they went from 4.23 to 4.24 so I'm hesitant to use 4.24 and 4.25 doesn't work so I'm still using MXCube 4.23 until they get the PLLM generation figured out.

Roman

Imen.D
ST Employee
Posted on April 04, 2018 at 15:47

Hello,

You are right, PLLM parameter

is no more generate for STM32L4 in the CubeMX

version 4.25

.

T

hisCubeMX bug passed internally to CubeMx team -again- for fix as it seems to be a regression issue after being fixed in version 4.23 and in version 4.25 for L4+ (

asmentioned in the Release note of STM32CubeMX

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fcontent%2Fccc%2Fresource%2Ftechnical%2Fdocument%2Frelease_note%2Fb2%2F02%2F4b%2Fe3%2F81%2F32%2F49%2Fc4%2FDM001076pdf%2Ffiles%2FDM001076pdf%2Fjcr%3Acontent%2Ftranslations%2Fen.DM001076pdf

).

Sorry for such inconvenience.

Best Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Houda GHABRI
ST Employee
Posted on April 12, 2018 at 10:58

Hello Motla,

Thanks for your feedback

The issue will be fixed next CubeMX release.

Please feel free to contact me for further details.

Best regards,

Houda

Posted on April 12, 2018 at 14:45

Hello Houda,

Are there any other STM32L4xx issues if I were to use CubeMX 4.25 besides it omitting the PLLM setting?

Roman

Houda GHABRI
ST Employee
Posted on May 10, 2018 at 18:45

Hi

Lamothe.Romain

,

CubeMX version 4.1

(in which thisissue is resolved) isavailable now on ST Website.

Regards,

Houda

Posted on May 10, 2018 at 19:20

Wonderful,

Thanks,

Roman Marjamaa

Marjamaa Engineering Inc.

395 Co Rd 110 N

Mound, MN 55364

Direct: (612) 999-8263

Mobile: (612) 345-1492

Fax: (855) 627-5364

www.marjamaaengineering.com<http://www.marjamaaengineering.com/>;

All information contained in this email is to be treated as “confidential� or “proprietary� and shall not be shared

outside the terms of the Agreement between Marjamaa Engineering Inc. and the Recipients of this email.