vApplicationIdleHook function was not being called at all

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.

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.

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?

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.

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.