cancel
Showing results for 
Search instead for 
Did you mean: 

Clock Configuration Issue: HAL_RCC_OscConfig HAL_TIMEOUT Error

xlin.1
Associate II

Hello ST Community,

I am encountering a clock configuration issue that I need assistance with.

I initially began with a blank template using an internal clock, and the code ran without any problems. However, when I attempted to configure a 24MHz external oscillator, I encountered an error loop during debugging. Here's the sequence of events:

  1. Started with a blank template using an internal clock - Code ran as expected without any issues.
  2. Configured the clock tree to use a 24MHz external oscillator, set the main clock rate to 170MHz, and allowed the clock tree to resolve the rest.
  3. Compiled and uploaded the code again, but it failed to progress beyond the SystemClock_Config stage.

Upon investigating further, I discovered that the HSE ready bit is not set in time for some reason during the clock configuration. As a result, HAL_RCC_OscConfig() returned HAL_TIMEOUT, leading the program into an error loop. I tried Increasing the timeout value from 100 to 1000 but it didn't help.

 

 

        /* Wait till HSE is ready */
        while (READ_BIT(RCC->CR, RCC_CR_HSERDY) == 0U)
        {
          if ((HAL_GetTick() - tickstart) > HSE_TIMEOUT_VALUE)
          {
            return HAL_TIMEOUT;
          }
        }

 

 

My clock tree is shown below:

Screenshot from 2024-01-08 16-02-53.png

I also recorded a 5-minute video of my process:

The code is uploaded in the zip attachment

I faced the same issue on two brand-new G431KB NUCLEO boards. I would appreciate any insights, suggestions, or guidance on resolving this issue. If anyone has encountered a similar problem or has expertise in clock configuration on this platform, your assistance would be invaluable.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @STOne-32 

Thank you for your quick response. I've located the G431 NUCLEO board schematic here:

https://www.st.com/resource/en/schematic_pack/mb1430-g431kbt6-a02_schematic_internal.pdf

Upon reviewing the schematic, I observed that the clock signal can be selected between the STLink Master Clock Output (MCO) and the 24MHz external oscillator by configuring soldering bridges (shown in the screenshot below). The issue with the previous clock error stemmed from none of the soldering bridges being connected on the new development board, leading to no clock signal being fed into the HSE pin.

xlin1_0-1704698985916.png

To address this, I plan to connect the SB9 and SB10 soldering bridges on the development board, as illustrated below:

416585805_1040017687256517_4119394251917308654_n.jpg

Your guidance has been immensely helpful in identifying the root cause of the problem. I appreciate your support.

Have a great day!

View solution in original post

2 REPLIES 2
STOne-32
ST Employee

Dear @xlin.1 

Can you provide the schematics and how the 24MHz crystal or 24MHz oscillator is connected to the HSE pins ? 
Have a good day,

STOne-32

Hi @STOne-32 

Thank you for your quick response. I've located the G431 NUCLEO board schematic here:

https://www.st.com/resource/en/schematic_pack/mb1430-g431kbt6-a02_schematic_internal.pdf

Upon reviewing the schematic, I observed that the clock signal can be selected between the STLink Master Clock Output (MCO) and the 24MHz external oscillator by configuring soldering bridges (shown in the screenshot below). The issue with the previous clock error stemmed from none of the soldering bridges being connected on the new development board, leading to no clock signal being fed into the HSE pin.

xlin1_0-1704698985916.png

To address this, I plan to connect the SB9 and SB10 soldering bridges on the development board, as illustrated below:

416585805_1040017687256517_4119394251917308654_n.jpg

Your guidance has been immensely helpful in identifying the root cause of the problem. I appreciate your support.

Have a great day!