The example usage in der API vTaskDelayUntil states the following:
// Perform an action every 10 ticks.
void vTaskFunction( void * pvParameters )
const TickType_t xFrequency = 10;
// Initialise the xLastWakeTime variable with the current time.
xLastWakeTime = xTaskGetTickCount();
for( ;; )
// Wait for the next cycle.
vTaskDelayUntil( &xLastWakeTime, xFrequency );
// Perform action here.
Can someone explain to me, why (and how) xLastWakeTime is a pointer?
Thanks in advance
I’m unsure what you mean with pointer ?
Did you read the API doc of vTaskDelayUntil ? There the pxPreviousWakeTime argument is explained.
Thank you Hartmut for your answer. I have read the API before but it became clear to me after lunch, that only because LastWakeTime is not defined as a pointer*, the function vTaskDelayUntil just takes the address& of LastWakeTime for comparison, instead of passing the value. This probably saves memory space and computation time.
The reason the LastWakeTime parameter is passed via a pointer is that vTaskDelayUntil updates its value with each call.
Basically, what vTaskDelayUntil does is update the LastWakeTime by adding its time to delay parameter, then waits for that time stamp to arrive, or returns immediately if that time stamp has already passed.
Thank you both, that clarified things for me.