I'm using an ARM Cortex-M4 microcontroller to develop an application with FreeRTOS.
For exact timing, I want use an interrupt based timer. The interrupt has an appropriate priority so it should be able to call the FreeRTOS API. The ISR is called periodically and should wake up a task as in the given code:
/* This function is executed by the task I'd like to resume */
void hello_task() {
while (1) {
vTaskSuspend(task);
printf("Tick\n");
}
}
/* The ISR is called by an interrupt about 200 times per second */
void Timer_IRQHandler() {
CLEAR_INTERRUPT_FLAG();
xTaskResumeFromISR(task);
}
The ISR is executed correctly but the task doesn't resume afterwards. Does anyone have an explaination for this behavior?
Thank you!
xTaskResumeFromISRwill actually not perform a context switch directly, but needs a portYIELD_FROM_ISR() at the end of the ISR to make it happen. - tofro