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

11 REPLIES 11
Khouloud ZEMMELI
ST Employee

​Hello @JBlaz.1​ 

Could you please share your ioc file ?

Thanks,

Khouloud

Hello @Khouloud ZEMMELI​ ,

I use platformio with HAL. Can you guide me to this file?

[env:disco_f407vg]
platform = ststm32
board = disco_f407vg
framework = arduino

Cheers

RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // external clock source rather than crystal

Make sure the 8 MHz is present from ST-LINK, not sure if any jumpers or solder bridges involved.

Make sure HSE_VALUE define is 8000000

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

You can either use the MCO output from ST-Link like clive1 says, or you can use the HSE crystal. In either case, consult UM1472 for the jumpers/components that need fitted/removed.

• MCO from ST-LINK. From MCO of the STM32F103. This frequency cannot be
changed, it is fixed at 8 MHz and connected to PH0-OSC_IN of the STM32F407VG.
Configuration needed:
– SB13, SB14 OPEN
– R25(b) removed
– R68(b) soldered
• Oscillator on board. From X2 crystal. For typical frequencies and its capacitors and
resistors, refer to the STM32F407VG Datasheet at www.st.com. Configuration needed:
– SB13, SB14 OPEN
– R25(b) soldered
– R68(b) removed

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

also from the manual:

b) As the frequency supplied by X2 is the same as MCO (8 MHz), R25 and R68 are soldered.

So, I didnt change anything.

Nevertheless, I removed R68 now and the result is the same - goes straight into "Error_Handler"

Thanks for your input. I changed as you suggested but still goes into "Error_Handler()"

HSE_VALUE is already set to 8000000U

​You have created a project from CubeMX , after the save, the CubeMX project is saved as .ioc file,  you can share you project .zip

Best Regards,

Khouloud

I use platformio, where do I find the ioc file? Or can I provide the information from an alternate location?

regards

Piranha
Chief II

You have the HAL source code and a board with a debugger - step through the code and look for where and why it fails!