Skip to main content
Visitor II
January 15, 2025
Question

Wait on HAL_GetTick not working

  • January 15, 2025
  • 1 reply
  • 1115 views

Hi everyone,

I'm new to STM32CubeIDE and encountering an issue with my code. It seems to halt at the following loop:

 

 while ((HAL_GetTick() - tickstart) < wait)
 {
 }

 

I've attached the .ioc file for reference. Can someone help me identify why the program gets stuck here and suggest a fix?

Thanks in advance!

    This topic has been closed for replies.

    1 reply

    Super User
    January 15, 2025

    Have you not properly configured the HAL tick?

    What if you use HAL_Delay() ?

    Did you see this note - found in many (most? all?)  of ST's examples:

     

    @note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds)
    based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from
    a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower)
    than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
    To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.

    @note The application need to ensure that the SysTick time base is always set to 1 millisecond
    to have correct HAL operation. -