cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 fails on HAL_RCC_OscConfig

JBlaz.1
Associate II

Hello guys,

I got a "STM32F407-DISC1" board and if I configure the external oscillator, it goes into "error_handling:

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
 
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
 
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
 
  RCC_OscInitStruct.PLL.PLLM = 8;
 
  RCC_OscInitStruct.PLL.PLLN = 336;
 
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
 
  RCC_OscInitStruct.PLL.PLLQ = 7;
 
 
 
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 
  {
 
 
 
    Error_Handler();
 
  }
 

Afterwards program stops and does not continue. What do I need to change in my code? or is it due to a hardware failure?

Cheers

This discussion is locked. Please start a new topic to ask your question.
11 REPLIES 11
TDK
Guru

Maybe you're trying to change the PLL while it's already enabled. Who knows. You're not providing much info.

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

+1

...or ditch Cube altogether and write the clock setup yourself.

JW

PS If you don't have a crystal but using the STLink MCO output, do you set HSE Bypass?