cancel
Showing results for 
Search instead for 
Did you mean: 

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

lwatcdr
Associate II

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

12 REPLIES 12

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
Up vote any posts that you find helpful, it shows what's working..
lwatcdr
Associate II

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

 

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
Up vote any posts that you find helpful, it shows what's working..

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.

 

Is your clock set to HSE bypass? That is the default on nucleo boards, without modifying solder bridges.

 

Edit: it is the default on some boards, but, importantly, not this one.

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

Yes it is.

 

Some Nucleo boards have "HSE not used" as the default solder bridge configuration; for example, Nucleo L4XX.

@Chris21 Thanks for the correction.

 

@lwatcdr It looks like on the NUCLEO-U5A5ZJ-Q, the 16 MHz crystal is hooked up by default, so HSE selection should be 16 MHz, non-bypass. Looks like CubeMX sets it to 8 MHz bypass by default for this board.

TDK_0-1727127985270.png

 

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

I have two questions

  1. So why does it fail only in debug but when I run not in debug.
  2. Where do I set the HSE to 16Mhz.