cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_RCC_OscConfig

willow
Associate III

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

13 REPLIES 13
SofLit
ST Employee

Hello @willow  and welcome to the community,

Could you please share your ioc file?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

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

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
}

 

 

 

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?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@SofLit wrote:

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


@willow is it a brand new board, straight from the factory, or has it had previous users and/or uses ?

Check especially that part of the board:

SofLit_0-1715766354457.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Yes in deed, im using the NUCLEO F401RE ! No i didnt modify the hardware

it has previous user and uses but always for my project purpose 

im gonna try do that and ill update you what it shows, thank you very much