Updated Apr 2025
vTaskDelayUntil()
task. h
1void vTaskDelayUntil( TickType_t *pxPreviousWakeTime,2 const TickType_t xTimeIncrement );
INCLUDE_vTaskDelayUntil
Delay a task until a specified time. This function can be used by periodic tasks to ensure a constant execution frequency.
This function differs from
vTaskDelay()
vTaskDelay()
vTaskDelay()
vTaskDelayUntil()
vTaskDelay()
vTaskDelay()
vTaskDelay()
vTaskDelay()
vTaskDelay()
Whereas
vTaskDelay()
vTaskDelayUntil()
It should be noted that
vTaskDelayUntil()
vTaskDelayUntil()
pxPreviousWakeTime
The constant
portTICK_PERIOD_MS
This function must not be called while the RTOS scheduler has been suspended by a call to
vTaskSuspendAll()
Parameters:
-
pxPreviousWakeTime
Pointer to a variable that holds the time at which the task was last unblocked. The variable must be initialised with the current time prior to its first use (see the example below). Following this the variable is automatically updated within
.vTaskDelayUntil() -
xTimeIncrement
The cycle time period. The task will be unblocked at time
. Calling(*pxPreviousWakeTime + xTimeIncrement)with the samevTaskDelayUntilparameter value will cause the task to execute with a fixed interval period.xTimeIncrement
Example usage:
1// Perform an action every 10 ticks.2void vTaskFunction( void * pvParameters )3{4 TickType_t xLastWakeTime;5 const TickType_t xFrequency = 10;67 // Initialise the xLastWakeTime variable with the current time.8 xLastWakeTime = xTaskGetTickCount();910 for( ;; )11 {12 // Wait for the next cycle.13 vTaskDelayUntil( &xLastWakeTime, xFrequency );1415 // Perform action here.16 }17}