2025-09-04 12:36 PM
Hello,
I'm hunting a bug probably caused by a race condition running multiple tasks and IRQ handlers under FreeRTOS on a STM32H75x MCU.
My code shall run a task after (DMA-) IRQ has fired using the Deferred Interrupt Handling method shown in this example using the CMSIS2 RTOS API. In rare situations, it seems that the task is started delayed, maybe blocked by another task of same priority.
All (DMA-/UART-/TIMER) IRQs have prio 5, all tasks have FreeRTOS prio "REALTIME".
The FreeRTOS example (comments removed) goes like this:
void vANInterruptHandler( void )
{
BaseType_t xHigherPriorityTaskWoken;
prvClearInterruptSource();
xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR( xHandlingTask, &xHigherPriorityTaskWoken );
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
I wonder how this can be implemented using the CMSIS RTOS API2.
My code, according to this example here, goes quite as follows:
void IrqHandler(void) {
osEventFlagsSet(evt_id, 0x00000001U);
// osThreadYield();
}
I wonder if this code is the correct translation/implementation of the FreeRTOS code above. Most certainly not, but I do not know what CMSIS RTOS function matches the portYIELD_FROM_ISR.
According to the documentation, osEventFlagSet() can be called in ISR function but osThreadYield() not, so I wonder what is the appropriate CMSIS implementation.
Any idea?
Thanks in advance