Skip to main content
Graduate
June 19, 2025
Solved

HAL_Delay blocks code

  • June 19, 2025
  • 9 replies
  • 843 views

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!

    This topic has been closed for replies.
    Best answer by TDK

     

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

    9 replies

    ST Employee
    June 19, 2025

    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.

    Graduate II
    June 19, 2025

    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.

    QuirinSAuthor
    Graduate
    June 19, 2025

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

    QuirinS_0-1750335876374.png

     

    Super User
    June 19, 2025

    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.

    QuirinSAuthor
    Graduate
    June 19, 2025

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

     

    TDKAnswer
    Super User
    June 19, 2025

     

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

    Graduate II
    June 19, 2025

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

    QuirinSAuthor
    Graduate
    June 19, 2025

    I checked the reset cause and the RCC_FLAG_PINRST was set, i disabled the reset pin by setting the nrst_mode = 2 with cube programmer but its still the same problem

    Graduate II
    June 19, 2025

    Do you start a watch dog timer? Have one on your board?

    Otherwise constantly resetting is more likely a hardware/board level issue.

    Perhaps scope NRST/NRESET pin check if it is periodic, and what that period is.

    Check supply isn't browning out

    Check VCAP pins if present, should have around 4u7 F total on them, and 1.25 V

    The Systick is normally enabled/started in HAL_Init() code.

    QuirinSAuthor
    Graduate
    June 25, 2025

    The Buck converter was the problem, thus causing a brownout