# Task not running after vTaskNotifyGiveFromISR

**URL:** <https://forums.freertos.org/t/task-not-running-after-vtasknotifygivefromisr/21350>\
**Category:** Kernel\
**Tags:** debug\
**Created:** [September 8, 2024, 8:40pm UTC](https://forums.freertos.org/t/task-not-running-after-vtasknotifygivefromisr/21350 "2024-09-08T20:40:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![juanpgg](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@juanpgg](https://forums.freertos.org/u/juanpgg)\
**Post date:** [September 8, 2024, 8:40pm UTC](https://forums.freertos.org/t/task-not-running-after-vtasknotifygivefromisr/21350/1 "2024-09-08T20:40:54Z")

</div>

Hi there FreeRTOS team!

I’m having a problem with a task not running after an interrupt.

This is a FreeRTOS project running on ESP32 microcontroller which has 2 CPUs. I have an interrupt to trigger a GPIO input.

```auto
static void IRAM_ATTR encoderIntCallBack()
{
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    vTaskNotifyGiveFromISR(rotatory_reader_task_handle, &xHigherPriorityTaskWoken);
    if (xHigherPriorityTaskWoken)
    {
        portYIELD_FROM_ISR();
    }
}

```

I added a counter++ in this interrupt and can confirm the number of times I trigger the GPIO equals the counter.  
The problem is that the task that should be triggered after this interrupt doesn’t trigger every time.  
I’ve about 10 tasks split into core 0 and core 1. All these tasks are using `ulTaskNotifyTake(pdTRUE, portMAX_DELAY);` to wait for notifications, so I’m pretty sure no other tasks are running at the same time the GPIO task should run.

Any idea on how can I debug this?

Thanks a lot in advance

---

<div class="post-metadata">

**Author:** ![tony-josi-aws](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@tony-josi-aws](https://forums.freertos.org/u/tony-josi-aws)\
**Post date:** [September 9, 2024, 5:20am UTC](https://forums.freertos.org/t/task-not-running-after-vtasknotifygivefromisr/21350/2 "2024-09-09T05:20:28Z")

</div>

@juanpgg

> All these tasks are using `ulTaskNotifyTake(pdTRUE, portMAX_DELAY);` to wait for notifications, so I’m pretty sure no other tasks are running at the same time the GPIO task should run.

You are calling `ulTaskNotifyTake` with _`xClearCountOnExit`_ as `pdTRUE`.

[refer - [ulTaskNotifyTake](https://www.freertos.org/Documentation/02-Kernel/04-API-references/05-Direct-to-task-notifications/03-ulTaskNotifyTake)]

> If an RTOS task notification is received and `xClearCountOnExit` is set to  
> `pdTRUE` then the RTOS task’s notification value is reset to 0 before `ulTaskNotifyTake()`  
> exits. This is equivalent to the value of a binary semaphore being left at zero (or empty, or ‘not available’) after a successful call to `xSemaphoreTake()`.

The ISR handler `encoderIntCallBack` might be calling the `vTaskNotifyGiveFromISR` multiple times, causing the notification value to be incremented, but the notification value instead of being decremented is reset as `xClearCountOnExit` is set when `ulTaskNotifyTake` is called.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [September 9, 2024, 9:47am UTC](https://forums.freertos.org/t/task-not-running-after-vtasknotifygivefromisr/21350/3 "2024-09-09T09:47:35Z")

</div>

> [@juanpgg](#):
>
> The problem is that the task that should be triggered after this interrupt doesn’t trigger every time.

How did you verify that? Also, please share your findings after changing ulTaskNotifyTake call to `ulTaskNotifyTake(pdFALSE, portMAX_DELAY);` as @tony-josi-aws suggested.
