vTaskDelay and vTaskDelayUntil ignored or stuck on a STM32 Cortex M0+

Hi All,

I’m having difficulties converting a working FreeRTOS project from a 6kb RAM 8bit Atmega4809 microcontroller to a 8kb RAM STM32g030* Cortex-M0+

I used the CubeMX tool inside STM32CubeIDE to setup the project.
Inside CubeMX you can configure FreeRTOS settings through CMSIS v1 or v2 interface.
I started with v1 and quickly noticed the 8kb RAM was not enough.
I saved some RAM by switching GPIO / interrupt settings to LL drivers instead of HAL.

I got to a point that I had 3 out of 6 tasks running but had to refactor a lot of code to use the CMSIS functions. But more and more discovered that CMSIS was missing functionality I needed.

I discovered that those were inside CMSIS v2 so tried that one.
But this is definitely not build for M0+ . RAM usage went sky high.

I tried to mix CMSIS v1 with normal FreeRTOS calls for the missing functionality, but I think this doesn’t work good for Queue and Task notifications.

So now new attempt was just implement FreeRTOS native as it was done on the 8 bit controller.
I’m using ARM CORTEX M0 port and tried to copy FreeRTOSConfig.h content from the CMSIS v1 experiment before removing it.

I got warning that I had duplicate functions (xPortSysTickHandler() and PendSV_Handler()) in stm32g0xx_it.h and port.h, I think it was CubeMX leftovers from switching CMSIS on and off. But I made those either __weak or deleted them from stm32g0xx_it.h

The issue is that Task do run sometimes only once or in other situation simply ignoring vTaskDelay()

static void tsk_alarm(void *pvParameters)
	uint32_t ulNotifiedValue;

	while (1) {

For example Task above let my buzzer sound continuously. So it is ignoring vTaskDelay or alarm_short() is stuck

I think by turning of FreeRTOS/CMSIS and try implementing the Native way, somehow my SysTick / Timers are not configured the right way?

In CubeMX TIM1is greyed out and not selectable.
Once touched the CubeMX options, there is no way back?

Can you examine the value of xTickCount variable and see if it is incrementing?

Do you have the following line in your FreeRTOSConfig.h?

#define xPortSysTickHandler SysTickHandler

#define xPortSysTickHandler SysTickHandler

TIM1 options are greyed out because in SYS tab I had Timebase TIM1.
Not sure if above define should be commented out or not?

The attempts to find a fix made everything worse, while debugging with just one task running the debugger is stuck in:


I started a new project with CMSIS v1 and ignore the wrappers using these steps.

I got one task running fine.
My second task is using queues and that is starting to break things again.
It hangs in:

The assert that you are hitting indicates that you are calling a queue API with NULL pointer. Can you share your queue related code?