cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with System Clock Configuration

TProt.1
Associate II

I am trying to program an STM32 MCU powered board that has the STM32F103R8T6 UNIT. I have figured out that while the program is executing the function called SystemClock_Config(); doesn't initialize the clock and goes to the error handler when croosing the line:

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

  Error_Handler();

 }

Then the Error_Handler() function goes inside the following while loop and the program never gets executed.

void Error_Handler(void)

{

 /* USER CODE BEGIN Error_Handler_Debug */

 /* User can add his own implementation to report the HAL error return state */

 __disable_irq();

 while (1)

 {

 }

 /* USER CODE END Error_Handler_Debug */

}

I have configured my clock to be from the external crystal at 16MHz, have set the HCLK at the maximum allowable frequency of 72MHz and finally run the clock issues resolver and everything seems to be fine. However the program goes to this inifinite while() loop at the error handler and obviously stays there. How could I get over this problem ? Any help would be really appreciated. Thank you in advance !

4 REPLIES 4
TDK
Guru

If HAL_RCC_OscConfig fails, it indicates there was an error initializing the clock. Maybe your crystal isn't soldered right, or the load caps are incorrect, or you're using an external clock and should be in bypass mode instead.

Is this a custom board? Can you show the schematic?

If you feel a post has answered your question, please click "Accept as Solution".
TProt.1
Associate II

Hello and thanks for the answer. This is a custom made board, I designed it. Well, while waiting for the answer I checked everything and found out that my the crystal load caps are wrong. By accident I connected two 2.2uF capacitors instead of two 12pF capacitor. I guess this is the problem and now the boards are useless, right ? Is there a way to avoid using the crystal and maybe use some internal clock of the chip, if it has ?

You can clock it using the internal HSI.
If you feel a post has answered your question, please click "Accept as Solution".
TProt.1
Associate II

Well, thank you very much. You kinda saved my life. The below configuration seems to be working, the LED is flashing as it should. The only problem it finds is at the point which is circled.

0693W00000ANblPQAT.png 

Is there maybe a way to fix this one as well ?