cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Delay is stuck in the main function.

MMust.5
Senior II

If I write HAL_Delay in the main function, then code execution gets stuck at this place.

int main
{
HAL_Delay(1);
}

Code execution does not exit the loop at this point.

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

I think because the SysTick_Handler interrupt is not executed and therefore uwTick is not incremented.
I set the SysTick timer to high priority, but nothing changed.

Why is SysTick_Handler not being executed?
SysTick_Handler should execute every 1 millisecond and increment the uwTick variable.

HAL_Delay in the while loop works correctly, HAL_Delay does not work in the main function.

pr.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Mike_ST
ST Employee

Hello,

you should probably call:

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

before the call to HAL_Delay()

View solution in original post

2 REPLIES 2
Mike_ST
ST Employee

Hello,

you should probably call:

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

before the call to HAL_Delay()

MMust.5
Senior II

Thanks.

:rolling_on_the_floor_laughing: I need to get some good sleep.