# Any known issue with xTaskNotifyStateClear() v10.2.0?

**URL:** <https://forums.freertos.org/t/any-known-issue-with-xtasknotifystateclear-v10-2-0/12054>\
**Category:** Kernel\
**Created:** [March 21, 2021, 9:17pm UTC](https://forums.freertos.org/t/any-known-issue-with-xtasknotifystateclear-v10-2-0/12054 "2021-03-21T21:17:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesk](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jamesk](https://forums.freertos.org/u/jamesk)\
**Post date:** [March 21, 2021, 9:17pm UTC](https://forums.freertos.org/t/any-known-issue-with-xtasknotifystateclear-v10-2-0/12054/1 "2021-03-21T21:17:07Z")

</div>

Either I am misunderstanding the API, xTaskNotifyStateClear or there must be a bug.

ulTaskNotifyTake(TRUE, 30000) returns immediately after even I clear any pending notifications by calling xTaskNotifyStateClear(NULL) right before I call ulTaskNotifyTake().  
Both functions are called by same task.  
And I triple-checked to make sure that there is absolutely no vTaskNotifyGive() called while those two functions are called.  
Obviously vTaskNotifyGive() is called several times before I call xTaskNotifyStateClear().  
This is all for testing to make sure xTaskNotifyStateClear() is working the way it’s described.

So below is a sequence of calls:  
Task A calls vTaskNotifyGive(TaskB\_Handle)  
Task A calls vTaskNotifyGive(TaskB\_Handle)  
Task A calls vTaskNotifyGive(TaskB\_Handle)  
Task B calls vTaskNotifyStateClear(NULL)  
Task B call vTaskNotifyTake(TRUE, 30000)  
Amazingly vTaskNotifyTake() returns immediately.

Does anyone know if I am misunderstanding something here?  
Appreciate help.  
Regards,  
James

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 21, 2021, 10:28pm UTC](https://forums.freertos.org/t/any-known-issue-with-xtasknotifystateclear-v10-2-0/12054/2 "2021-03-21T22:28:07Z")

</div>

A misunderstanding I think. Tasks have a notification state and a notification value. As per the [API docs](https://www.freertos.org/ulTaskNotifyTake.html), “Where as [xTaskNotifyWait()](https://www.freertos.org/xTaskNotifyWait.html) will return when a notification [state] is pending, ulTaskNotifyTake() will return when the task’s notification value is not zero, decrementing the task’s notification value before it returns.” ulTaskNotifyTake() will return if its notification value is non zero - clearing the task’s notification state doesn’t change the notification value.

Curious as to why this is noted to be a ‘known issue’?

---

<div class="post-metadata">

**Author:** ![jamesk](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jamesk](https://forums.freertos.org/u/jamesk)\
**Post date:** [March 21, 2021, 11:26pm UTC](https://forums.freertos.org/t/any-known-issue-with-xtasknotifystateclear-v10-2-0/12054/3 "2021-03-21T23:26:56Z")

</div>

Thanks Richard for your reply.  
I updated the title to be “Any known issue with xTaskNotifyStateClear() v10.2.0?”  
I meant it to be a question not a statement. 🙂

So I should have used xTaskNotifyWait() instead of xTaskNotifyTake() in my scenario.  
Looks like then I have to use xTaskNotifyWait() although I do not need multi bit notifications.
