cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Delay blocks code

QuirinS
Associate II

Hello, I have a custom board wich is based on the evspin32g4-dual Board. I generated the code with motorcontrol work bench and could upload it with a j-link. I added an uart output in the startup and noticed that it kept printing it, so the board was constantly resetting. When I stepped through the code the problem was in HAL_Delay, as the HAL_GetTick() function always returned the same value, thus not leaving the function. Could there be an error with the external Crystal? I am using a ECS-240-8-37-CKM-TR with 8pF caps.

Screenshot 2025-06-19 130223.png

Thanks!

7 REPLIES 7
Sarra.S
ST Employee

Hello @QuirinS

The HAL_GetTick() function relies on the SysTick timer, which in turn depends on a stable clock source, so yes, probably it's an issue with the crystal. 

You can refer to AN2867 for oscillator design guidelines.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

LCE
Principal II

I would try to verify this by building a version using the internal oscillator (HSI).

Check the PLL settings to get the same system clock rate as with the HSE.

QuirinS
Associate II

Thanks for your reply, I just checked the project and HSI is already in use. 

QuirinS_0-1750335876374.png

 

TDK
Super User

If the code is running, it's not likely a crystal problem.

Probably you're calling HAL_Delay in an interrupt context, or with interrupts disabled.

Set SysTick priority to 0 and everything else above that.

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

I was able to step over the delay and ran into a breakpoint in SysTick_Handler, so the reset is caused by something else.

 

LCE
Principal II

Well, then "run a little further"! ;) 

 

If it's resetting, look at RCC->CSR after startup to determine why.

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