Updated Apr 2025
vTaskStepTick
task.h
1 void vTaskStepTick( TickType_t xTicksToJump );
If the RTOS is configured to use tickless idle functionality then the tick interrupt will be stopped, and the microcontroller placed into a low power state, whenever the Idle task is the only task able to execute. Upon exiting the low power state the tick count value must be corrected to account for the time that passed while it was stopped.
If a FreeRTOS port includes a default portSUPPRESS_TICKS_AND_SLEEP() implementation, then
vTaskStepTick()
vTaskStepTick()
portSUPPRESS_TICKS_AND_SLEEP()
portSUPPRESS_TICKS_AND_SLEEP()
The
configUSE_TICKLESS_IDLE
vTaskStepTick()
Parameters:
-
xTicksToJump
The number of RTOS ticks that have passed since the tick interrupt was stopped. For correct operation the parameter must be less than or equal to the
parameter.portSUPPRESS_TICKS_AND_SLEEP()
Returns:
None.
Example usage:
The example shows calls being made to several functions. Only
vTaskStepTick()
1/* First define the portSUPPRESS_TICKS_AND_SLEEP(). The parameter is the time,2 in ticks, until the kernel next needs to execute. */3#define portSUPPRESS_TICKS_AND_SLEEP( xIdleTime ) vApplicationSleep( xIdleTime )45/* Define the function that is called by portSUPPRESS_TICKS_AND_SLEEP(). */6void vApplicationSleep( TickType_t xExpectedIdleTime )7{8 unsigned long ulLowPowerTimeBeforeSleep, ulLowPowerTimeAfterSleep;910 /* Read the current time from a time source that will remain operational11 while the microcontroller is in a low power state. */12 ulLowPowerTimeBeforeSleep = ulGetExternalTime();1314 /* Stop the timer that is generating the tick interrupt. */15 prvStopTickInterruptTimer();1617 /* Configure an interrupt to bring the microcontroller out of its low power18 state at the time the kernel next needs to execute. The interrupt must be19 generated from a source that is remains operational when the microcontroller20 is in a low power state. */21 vSetWakeTimeInterrupt( xExpectedIdleTime );2223 /* Enter the low power state. */24 prvSleep();2526 /* Determine how long the microcontroller was actually in a low power state27 for, which will be less than xExpectedIdleTime if the microcontroller was28 brought out of low power mode by an interrupt other than that configured by29 the vSetWakeTimeInterrupt() call. Note that the scheduler is suspended30 before portSUPPRESS_TICKS_AND_SLEEP() is called, and resumed when31 portSUPPRESS_TICKS_AND_SLEEP() returns. Therefore no other tasks will32 execute until this function completes. */33 ulLowPowerTimeAfterSleep = ulGetExternalTime();3435 /* Correct the kernels tick count to account for the time the microcontroller36 spent in its low power state. */37 vTaskStepTick( ulLowPowerTimeAfterSleep - ulLowPowerTimeBeforeSleep );3839 /* Restart the timer that is generating the tick interrupt. */40 prvStartTickInterruptTimer();41}