I am using FreeRTOS with STM32G0 series. I created two tasks in the beginning it goes to two task but after couple of times it always stuck in one task

FreeRTOS task has been stuck with one of them not going to other task. I used STCube to generate the code and created two tasks, i assume idle task is created by RTOS so i have not done. In the beginning it run both the tasks but after 3 or 4 times it always stuck in one task. I am new to using FreeRTOS . Please guide me.

Here are a few “basics” that have helped many new users. Be sure you have configASSERT() defined and that you enable stack overflow checking and use the malloc-failed hook .

And with Cortex M, the FAQ is especially helpful:

1 Like

If you are generating your project using STM32CubeIDE, another thing to keep in mind to change the HAL Tick from SysTick to some other timer (say TIM6): System Core --> SYS --> Timebase Source.

Thanks.

1 Like

/****** Cortex-M0+ Processor Exceptions Numbers **************************************************************/
NonMaskableInt_IRQn = -14, /
!< 2 Non Maskable Interrupt /
HardFault_IRQn = -13, /
!< 3 Cortex-M Hard Fault Interrupt /
SVC_IRQn = -5, /
!< 11 Cortex-M SV Call Interrupt /
PendSV_IRQn = -2, /
!< 14 Cortex-M Pend SV Interrupt /
SysTick_IRQn = -1, /
!< 15 Cortex-M System Tick Interrupt */

These are generated by STMCube. /* System interrupt init*/
/* PendSV_IRQn interrupt configuration */
HAL_NVIC_SetPriority(PendSV_IRQn, 3, 0); this function is called in HAL_MspInit. Is this is an issue? Memory i am using dynamic allocation so the issue may not be related to stack.

I am using TIM6 as time base for HAL

I afraid a few more details are needed to help.
Could you post the code of the tasks and where exactly the task is stuck ?
And also the code where you create the tasks ?
Did you already take care about Jeff’s hints ? I also strongly recommend doing so during development.