Skip to main content
Graduate II
May 15, 2024
Solved

HAL_RCC_OscConfig

  • May 15, 2024
  • 2 replies
  • 4461 views

Hello everyone, 

I am configuring an STM32F401RE and its RTC on the STM32CubeIDE software

I've written an program that debug without errors. But ErrorHandler() is called during the RCC Oscillators initialization (during the "SystemClock_Config(void)" process).

 

I think i'have followed the steps and the right parameters, but would you have a clue of where could it be from ? Let me know if you need additional pictores of the system configuration of the .ioc file maybe

 

 

 

 

 

 

/** Initializes the RCC Oscillators according to the specified parameters

 * in the RCC_OscInitTypeDef structure.

 */

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE;

 RCC_OscInitStruct.LSEState = RCC_LSE_ON;

 RCC_OscInitStruct.HSIState = RCC_HSI_ON;

 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;

 RCC_OscInitStruct.PLL.PLLM = 16;

 RCC_OscInitStruct.PLL.PLLN = 336;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;

 RCC_OscInitStruct.PLL.PLLQ = 7;



if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

 Error_Handler(); //the call of ErrorHandler() happens here

 }

 

 

 

willow_0-1715762138855.png

willow_1-1715762168200.png

willow_0-1715762228368.png

 

 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello @willow ,

    Thank you for sharing the file.

    I didn't reproduce the behavior with NUCLEO-F401 board. Could you confirm you're using that board?

    Also did you modify something on it? especially LSE part of the board?

    2 replies

    Technical Moderator
    May 15, 2024

    Hello @willow  and welcome to the community,

    Could you please share your ioc file?

    willowAuthor
    Graduate II
    May 15, 2024

    Of course @mƎALLEm and thank you for your answer, here is my .ioc file attached

    mƎALLEmAnswer
    Technical Moderator
    May 15, 2024

    Hello @willow ,

    Thank you for sharing the file.

    I didn't reproduce the behavior with NUCLEO-F401 board. Could you confirm you're using that board?

    Also did you modify something on it? especially LSE part of the board?

    Super User
    May 15, 2024

    Another Top Tip -  for debugging:

     

    The return values from functions like HAL_RCC_OscConfig() are there to tell you what went wrong - so make sure you have some way to see what was returned.

    eg, instead of just

    if( HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK )
    {
     Error_Handler(); //the call of ErrorHandler() happens here
    }

    do:

    HAL_StatusTypeDef HAL_result; // Have a variable to catch the result
    
    HAL_result = HAL_RCC_OscConfig(&RCC_OscInitStruct); // Catch the result
    
    if( HAL_result != HAL_OK )
    {
     // Now you can put a breakpoint here, 
     // and see what is in HAL_result 
    
     Error_Handler(); //the call of ErrorHandler() happens here
    }

     

     

     

    Technical Moderator
    May 15, 2024

    Check especially that part of the board:

    SofLit_0-1715766354457.png