Couldn't run the scheduler after handling timer 5 Interrupt

Dear RTOS Hello,
I am getting started with FreeRTOS on stm32F429 board,
I download the FreeRTOS and, I integrated it into an example from ST respo. I am not using the CubeMx.
The first time I run the FreeRTOS with one static task, it works well.
I am trying to add the timer 5 interrupt and yiel from interrupt. The execution code stop in vPortRaiseBASEPRI function.
I am activating the configASSERT in the FreeRTOSConfig but my program still not working!

void TIM5_IRQHandler(void)

#if 1

	BaseType_t xHigherPriorityTaskWoken = pdFALSE;

	xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken);
	//xHigherPriorityTaskWoken = xTaskResumeFromISR(LED_TaskRed);





When I use the interrupt directly, I could see my LEDs blinking.
This is the stack calling function :
I have one more question please, does I have to use any UART interface to make ASSERT methods and API work?
Thank you in advance,

First, you do not need a UART to use configASSERT, as typically configASSERT will just halt in a loop that you use the debugger to break and see that it happened.

My first guess is that you have not set the priority of this ISR, so its default of 0 is too ‘high’ (on ARM M’s lower values of interrupt priority are higher priority to the interrupt).

Hello richard-damon,
Thank you for your replay,

Ok, Since my interrupt is the highest priority, why this interrupt is not executed?
Thank you in advance,

The priority is too high if using FreeRTOS calls in this ISR. That’s the reason for the assert.
The choosen prio has to match configMAX_SYSCALL_INTERRUPT_PRIORITY in your FreeRTOSConfig.h
See and mabe also this pretty good picture for details.

My interrupt prio also is 5. It makes sense that my timer interrupt is masked.
In this situation what do you recommend me to do?
I am using the STM32f429 board with cube ide. and cubeMx.

Thank you in advance,

I afraid that’s not yet correct. You should e.g.
and use the configMAX_SYSCALL_INTERRUPT_PRIORITY macro as done in this demo example:

/* Cortex-M specific definitions. */
	/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
	#define configPRIO_BITS       		__NVIC_PRIO_BITS
	#define configPRIO_BITS       		4        /* 15 priority levels */

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
PRIORITY THAN THIS! (higher priorities are lower numeric values. */

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See */

And as far as I remember there is hint in the mentioned FreeRTOS docs regarding using STM32 drivers and NVIC priority grouping.

Sorry - I’m not familiar with cube. But I thought it generates all required files/configs…

My FreeRTOSConfig.h file is the same as you minched.

I didn’t understand what are you saying in this sentence. Could you clarify please?

If you’d read the documentation I already mentioned you’d find:

Maybe that’s done by cube generated code, maybe not. I’d double-check that.

Edit I didn’t find TIM5 in your screenshot :thinking:

Non, I am using TIM6 for interrupt trigger, and TIM1 for FreeRTOS.
I will test the call function of NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); and will comment the results.
Thank you for help :slight_smile:

Did you change the TIM from 5 to 6 since the first post ? The topic and also the backtrace refer to TIM5 …

Yes, The TIM3.CNT register is always 0. I changed the timer to test.

Hello again,
I resolve the problem of the interrupt trigger,
I have this message in the Debugger console when the timer is runing for the first time:

Program stopped.
xQueueGiveFromISR (xQueue=0x0, pxHigherPriorityTaskWoken=0x2002ff5c) at …/Middlewares/Third_Party/FreeRTOS/Source/queue.c:1120
1120 configASSERT( pxQueue );

Now, my interrupt is triggered but the program is stopped at this point.
I am calling this function before running the rtos HAL_NVIC_SetPriorityGrouping (NVIC_PRIORITYGROUP_4);

So did you finally resolve the problem or are you still stuck ?
If you still having the problem it seems that the xSemaphore is not yet created (NULL) when the ISR is entered 1st time.
You have to ensure that all resources used in ISRs are created and initialized before activating the corresponding interrupt.
In your specific case xSemaphore has to be created before enabling TIMx interrupt

My problem is solved, thank you so much.
The semaphore was declared before the init timer, so the semaphore was null.
The HAL_NVIC_SetPriorityGrouping (NVIC_PRIORITYGROUP_4); call before the scheduler solved the priority issue, I will dig into the details and reading the documentation for more understanding.
Have a nice day.

How come configASSERT() didn’t catch these problems right at the beginning?

I think that the assert caught that before but I didn’t see the console output.
This is the first time I use FreeRTOS with STM32F4 microcontroller.

let me add that there are ready-to-use examples in the last version of STM32CubeF4 Fw package (

Once you download it, you find FreeRTOS ready to use examples for the STM32F429 discovery board at the following path:

This could help on this and possible future questions.
Best Regards

Thank you massimopanzica,
The STM examples projects are very helpful and very easy to use.
I would like to use CubeMx with cubeIDE and have the ability to add and remove peripherals, change the clock frequency…