cancel
Showing results for 
Search instead for 
Did you mean: 

Use of "HAL_Delay" after "osThreadCreate"

Dev1
Associate II

Hi all,

I am working with the Nucleo-L476RG board.

I generated a project with CubeMx and enabling FreeRTOS.

At this point the project is running fine.

I debug the project and all is working.

I put a breack point inside the "SysTick_Handler" and this hadler is always launching.

Now, in main function, I add "HAL_Delay(1000)" after creation of the default task with "osThreadCreate" function:

0690X000008A7VVQA0.png

When I debug this code, the "SysTick_Handler" is never launching.

And the code hangs in the "HAL_Delay" function where "HAL_GetTick()" function returns always 0.

I read at https://community.st.com/s/question/0D50X00009XkYFaSAN/freertos-stm32-tick

that If Iwant to use HAL_Delay() before vTaskStartScheduler (osKernelStart), I need to check scheduler state before call xPortSysTickHandler:

I add this check in "SysTick_Handler":

0690X000008A7qYQAS.png

BUT the problem persists because the "SysTick_Handler" was never launched.

Can anyone please found the cause of this problem.

I now that I can overwrite the "HAL_Delay" function since it is "weak", but I need to know the cause of this problem.

Is there any missing configuration ?

Thank you.

10 REPLIES 10

@Yassine1 I don't think there is anything to overcome -- one just needs to be aware of the issue and write one's code accordingly.