Skip to main content
Associate II
May 15, 2024
Solved

HAL_RCC_OscConfig

  • May 15, 2024
  • 2 replies
  • 4463 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

mƎALLEm
Technical Moderator
May 15, 2024

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."
willowAuthor
Associate II
May 15, 2024

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

mƎALLEm
mƎALLEmBest answer
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?

"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."
Andrew Neil
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
}

 

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mƎALLEm
Technical Moderator
May 15, 2024

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."