Task stuck in ready state on cortex-M33

In “I2C2_EV_IRQHandler()”, I think you need:

  1. Add a local variable with type BaseType_t, for instance, “xTaskWoken”; this will used to tell the kernel whether to call the scheduler when the IRQ handler exits
  2. In the call to “xSemaphoreGiveFromISR()”, replace the second parameter with “&xTaskWoken”; if a task is waiting on the semaphore, “xTaskWoken” will be set to “pdTRUE”, otherwise it will be set to “pdFALSE
  3. Immediately after the call to “xSemaphoreGiveFromISR()”, add a call to “portYeild_FROM_ISR(xTaskWoken)”; this tells the scheduler whether to perform a context switch when the interrupt handler returns.

I don’t know if this will solve your problem, but I recommend trying it. In the latest “Mastering the FreeRTOS™ Real Time Kernel” (see New FreeRTOS Kernel book released), example 7.1 shows how this works and probably explains it better than I can.

1 Like