2

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 :

  • New STM32 Project in STM32CubeIDE, everything by default
  • Open the ioc file in MX perspective, add FreeRTOS support with CMSIS_V2 interface
  • In main.c, after osKernelInitialize(), add
    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?

Gwen
  • 1,436
  • 3
  • 23
  • 31

2 Answers2

0

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.

0___________
  • 60,014
  • 4
  • 34
  • 74
  • Thanks for the reply. Since I placed this code before `osKernelStart`, `osDelay`/`vTaskDelay` cannot be used there (tasks not running yet). I was doing any things before `osKernelStart`, I guess that was my mistake. – Gwen Mar 14 '23 at 09:20
0

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.

Gwen
  • 1,436
  • 3
  • 23
  • 31