Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Updated Apr 2025

vTaskStepTick

[RTOS Kernel Control]

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()
is used internally to ensure the correct tick count value is maintained.
vTaskStepTick()
is a public API function to allow the default
portSUPPRESS_TICKS_AND_SLEEP()
implementation to be overridden, and for a
portSUPPRESS_TICKS_AND_SLEEP()
to be provided if the port being used does not provide a default.

The

configUSE_TICKLESS_IDLE
configuration constant must be set to 1 for
vTaskStepTick()
to be available.

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

    portSUPPRESS_TICKS_AND_SLEEP()
    parameter.

Returns:

None.

Example usage:

The example shows calls being made to several functions. Only

vTaskStepTick()
is part of the FreeRTOS API. The other functions are specific to the clocks and power saving modes available on the hardware in use, and as such, must be provided by the application writer.

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 )
4
5/* Define the function that is called by portSUPPRESS_TICKS_AND_SLEEP(). */
6void vApplicationSleep( TickType_t xExpectedIdleTime )
7{
8 unsigned long ulLowPowerTimeBeforeSleep, ulLowPowerTimeAfterSleep;
9
10 /* Read the current time from a time source that will remain operational
11 while the microcontroller is in a low power state. */
12 ulLowPowerTimeBeforeSleep = ulGetExternalTime();
13
14 /* Stop the timer that is generating the tick interrupt. */
15 prvStopTickInterruptTimer();
16
17 /* Configure an interrupt to bring the microcontroller out of its low power
18 state at the time the kernel next needs to execute. The interrupt must be
19 generated from a source that is remains operational when the microcontroller
20 is in a low power state. */
21 vSetWakeTimeInterrupt( xExpectedIdleTime );
22
23 /* Enter the low power state. */
24 prvSleep();
25
26 /* Determine how long the microcontroller was actually in a low power state
27 for, which will be less than xExpectedIdleTime if the microcontroller was
28 brought out of low power mode by an interrupt other than that configured by
29 the vSetWakeTimeInterrupt() call. Note that the scheduler is suspended
30 before portSUPPRESS_TICKS_AND_SLEEP() is called, and resumed when
31 portSUPPRESS_TICKS_AND_SLEEP() returns. Therefore no other tasks will
32 execute until this function completes. */
33 ulLowPowerTimeAfterSleep = ulGetExternalTime();
34
35 /* Correct the kernels tick count to account for the time the microcontroller
36 spent in its low power state. */
37 vTaskStepTick( ulLowPowerTimeAfterSleep - ulLowPowerTimeBeforeSleep );
38
39 /* Restart the timer that is generating the tick interrupt. */
40 prvStartTickInterruptTimer();
41}