Gwen
Gwen

Reputation: 1450

STM32 HAL tick hangs after FreeRTOS mutex creation

After creation of a FreeRTOS mutex, the HAL Tick timer is not increasing anymore. I use STM32CubeIDE 1.11.2 as IDE and CubeMX 6.7.0 as code generator, test platform Nucleo-F767ZI.

Reproductibility :

    osMutexId_t mutex = osMutexNew(0);
    HAL_Delay(100);

Result : this code should stay stuck in HAL_Delay(). SysTick_Handler is never called anymore, HAL_GetTick() always retrun the same value (10 in my case).

I tried with CMSIS as well as FreeRTOS mutex functions, result is the same. I tried changing the time base for SysTick, same. I tried with another Nucleo, same.

What did I miss?

Upvotes: 2

Views: 800

Answers (3)

Pararera
Pararera

Reputation: 372

HAL tick uses system timer when RTOS is not used. Debugger is your friend. Find where HAL_IncTick called and place break point while debugging.

Upvotes: 0

Gwen
Gwen

Reputation: 1450

From what I have read, it is rather bad practice to put a lot of code before osKernelStart, especially everything related to FreeRTOS calls.

I moved all my initialization code into one task and used a semaphore to start the loops of the other tasks only after the initializations were done, and all the problems were solved.

Upvotes: -2

0___________
0___________

Reputation: 67810

You have interrupts priority problem in your code. If you prefer to use HAL_Delay instead of RTOS delay then I would suggest to use different timebase timer for the freeRTOS kernel. You can use the same but I would not recooment doing it before you start the scheduler. I would also strongly not advice to call any freeRTOS functions before you start the scheduler.

Upvotes: 0

Related Questions