This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

IDLE task behaviour of FreeRTOS

Hi,

I use FreeRTOS for ble application on nRF52840.

To save current consumption, I want to add __WFE() to portTASK_FUNCTION().

There is a comment in the function as below.

/* It is not desirable to suspend then resume the scheduler on
each iteration of the idle task. Therefore, a preliminary
test of the expected idle time is performed without the
scheduler suspended. The result here is not necessarily
valid. */

Then I want to ask you check adding __WFE() like below is safe or not.

The line number is 114.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static portTASK_FUNCTION( prvIdleTask, pvParameters )
{
/* Stop warnings. */
( void ) pvParameters;
/** THIS IS THE RTOS IDLE TASK - WHICH IS CREATED AUTOMATICALLY WHEN THE
SCHEDULER IS STARTED. **/
/* In case a task that has a secure context deletes itself, in which case
the idle task is responsible for deleting the task's secure context, if
any. */
portTASK_CALLS_SECURE_FUNCTIONS();
#if defined(DBGMON_ENABLE) && defined(DBGMON_TASK_COMMAND)
xStartTickCount = xTickCount;
xSleepTickCount = 0;
#endif
for( ;; )
{
/* See if any tasks have deleted themselves - if so then the idle task
is responsible for freeing the deleted task's TCB and stack. */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thank you.