# vApplicationIdleHook function was not being called at all

**URL:** <https://forums.freertos.org/t/vapplicationidlehook-function-was-not-being-called-at-all/14242>\
**Category:** NXP\
**Created:** [January 18, 2022, 4:00am UTC](https://forums.freertos.org/t/vapplicationidlehook-function-was-not-being-called-at-all/14242 "2022-01-18T04:00:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DesmondLim](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@DesmondLim](https://forums.freertos.org/u/DesmondLim)\
**Post date:** [January 18, 2022, 4:00am UTC](https://forums.freertos.org/t/vapplicationidlehook-function-was-not-being-called-at-all/14242/1 "2022-01-18T04:00:43Z")

</div>

I am using one of the NXP MIMXRT1062EVK to work with FreeRTOS.

Unfortunately, I found out that there are a lot of troubles using the FreeRTOS. Anyway, I will post more questions regarding the other matters in another topic. But, first, I could not figure out why vApplicationIdleHook function was not able to work at all in my code.

1. In the FreeRTOSConfig.h:

#define configUSE\_PREEMPTION 1  
#define configUSE\_TICKLESS\_IDLE 0

#define configIDLE\_SHOULD\_YIELD 1  
#define configUSE\_IDLE\_HOOK 1

1. In the main.c

void vApplicationIdleHook(void)  
{  
PRINTF(“IdleHook is working\r\n”);  
}

1. In the tasks.c (Original code)

static portTASK\_FUNCTION( prvIdleTask, pvParameters )  
{  
…  
#if ( configUSE\_IDLE\_HOOK == 1 )  
{  
extern void vApplicationIdleHook( void );

```
            /* Call the user defined function from within the idle task. This
             * allows the application designer to add background functionality
             * without the overhead of a separate task.
             * NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,
             * CALL A FUNCTION THAT MIGHT BLOCK. */
            vApplicationIdleHook();
        }
    #endif /* configUSE_IDLE_HOOK */

```

…  
}

This is rather straightforward code but, I have no idea why this is not working at all.

I am checking the other tasks running and I noticed I have put all the tasks around 10mins delay interval and I was think if the IdleHook will be able to call but I did not get any response at all (the breakpoint is not trigger at all).

Can any FreeRTOS experts let me know if I have missed out/set wrongly on any settings in order for me to trigger the ApplicationIdleHook functions?

Thanks.

---

<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:** [January 18, 2022, 5:10am UTC](https://forums.freertos.org/t/vapplicationidlehook-function-was-not-being-called-at-all/14242/2 "2022-01-18T05:10:56Z")

</div>

I would guess the idle task is being starved of processing time. If you pause the debugger when you think the idle task should be running, which task is acutely running? You can view pxCurrentTCB in the debugger, where you should be able to see the task name.

---

<div class="post-metadata">

**Author:** ![DesmondLim](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@DesmondLim](https://forums.freertos.org/u/DesmondLim)\
**Post date:** [January 18, 2022, 5:37am UTC](https://forums.freertos.org/t/vapplicationidlehook-function-was-not-being-called-at-all/14242/3 "2022-01-18T05:37:39Z")

</div>

> [@rtel](#):
>
> sk should be running

From the single stepping, it seems like IDLE is running but, it is not flowing to the ApplicationIdleHook(). It went to the TaskYield and quit itself.

Just now, I have also tried to #define configIDLE\_SHOULD\_YIELD 0, but to no avail as well.  
Any ideas why this is a problem for me?

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/d/dc939845fd26a618632e9f3b711cc537945685b6.png)

---

<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:** [January 18, 2022, 6:07am UTC](https://forums.freertos.org/t/vapplicationidlehook-function-was-not-being-called-at-all/14242/4 "2022-01-18T06:07:55Z")

</div>

If you are able to step through the code when the idle task is running you should be able to see exactly what it is doing. My next guess I would be you are not running the code you are compiling. That could be because you are programming the flash in the chip but running the code in a simulator, or may you just aren’t programming the flash at all and running what was previously in the flash, or some other reason.

---

<div class="post-metadata">

**Author:** ![DesmondLim](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@DesmondLim](https://forums.freertos.org/u/DesmondLim)\
**Post date:** [January 18, 2022, 6:59am UTC](https://forums.freertos.org/t/vapplicationidlehook-function-was-not-being-called-at-all/14242/5 "2022-01-18T06:59:28Z")

</div>

Hi rtel,

Thank you for your help. I manage to resolve the issue as I noticed that for some reasons, I have two FreeRTOSConfig.h lying around in two different places. Bummer.

I removed one and viola, it works like magic. That is the reason why I want to say cut and paste is really a very bad practice for programmers.
