AnsweredAssumed Answered

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

Question asked by motla on Mar 20, 2018
Latest reply on May 10, 2018 by marjamaa.roman

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

Outcomes