Skip to main content
Associate
Sep 23, 2024 5:04 PM UTC
Question

READ_BIT(RCC->CR, RCC_CR_HSERDY) fails with a HAL_TIMEOUT when running blinky in debug.

While in debug I get and error in this line of code. I do not get an error when running code not in debug.

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

SBC NUCLEO-U5A5ZJ-Q

CUBEMX IDE

This topic has been closed for replies.

14 replies

Tesla DeLorean
Guru
Sep 23, 2024 5:10 PM UTC

It takes too long, or the HSE is not present / connected.

Check board level jumper or solder-bridges (SB)

Clock typically derived from MCU providing ST-LINK, the frequency and presence of this can be changed/disabled

Check the HSE is populated, or wired to another source.

Check Systick isn't clocking faster than anticipated.

 

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
lwatcdrAuthor
Associate
Sep 23, 2024 5:24 PM UTC

I left out on detail it works fine when I run it but fails when I am trying to debug it

 

Tesla DeLorean
Guru
Sep 23, 2024 6:10 PM UTC

Humans run more slowly..

Are you single-stepping this?

Check DBGMCU settings/options, if it is allowing interrupts to continue whilst stopped? How is HAL_Delay() / HAL_GetTicks() implemented in your build?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
lwatcdrAuthor
Associate
Sep 23, 2024 6:21 PM UTC

No that would take forever. I have used break points to find where the error is set. I increased the HSE time out to 10000 so it should be plenty of time.
Start in debug. Hit continue. It runs and then hits a breakpoint on the return a time_out. 
No single stepping was used in the creation of this issue.

 

Roger SHIVELY
ST Employee
Sep 24, 2024 8:46 PM UTC

Hello @lwatcdr 

This post has been escalated to the ST Online Support Team for additional assistance.  We'll contact you directly.

 

Regards,

Roger

ST Support

CToun.1
Associate
Oct 8, 2024 7:46 AM UTC

I am encountering the same mentioned problem. Could you please share the solution or any guidance on how to resolve it?

Graduate
Jan 8, 2025 9:32 AM UTC

Facing the same problem here. 

I've tried setting the input frequency to 16 as suggested, but that didn't help.

Any other solutions?

 

PS: I've downloaded and installed the latest versions of STM32CubeIDE and STM32CubeMX today.

Here are some detail pictures of my board. I think these are the correct default settings. (I got the board from a customer. I don't think they changed anything to the jumpers.)

2025-01-08 10.52.47.jpg2025-01-08 10.52.19.jpg

Graduate
Jan 8, 2025 12:10 PM UTC

Never mind. Found the fix. 

The setting for HSE must be set to 'Crystel/Ceramic Resonator', just like with the LSE. 

Now I can debug my project.

 

Hneel_0-1736338196707.png