# Task stuck in ready state on cortex-M33

**URL:** <https://forums.freertos.org/t/task-stuck-in-ready-state-on-cortex-m33/19696>\
**Category:** Kernel\
**Tags:** debug\
**Created:** [April 2, 2024, 1:54am UTC](https://forums.freertos.org/t/task-stuck-in-ready-state-on-cortex-m33/19696 "2024-04-02T01:54:05Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![danielglasser](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@danielglasser](https://forums.freertos.org/u/danielglasser)\
**Post date:** [April 3, 2024, 12:08am UTC](https://forums.freertos.org/t/task-stuck-in-ready-state-on-cortex-m33/19696/7 "2024-04-03T00:08:49Z")

</div>

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](https://forums.freertos.org/t/new-freertos-kernel-book-released/19465)), example 7.1 shows how this works and probably explains it better than I can.

---

_[View the full topic](https://forums.freertos.org/t/task-stuck-in-ready-state-on-cortex-m33/19696)._
