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 Mar 2025

xTimerGetExpiryTime

[Timer API]

timers.h

1 TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );

Returns the time at which the software timer will expire, which is the time at which the timer's callback function will execute.

If the value returned by xTimerGetExpiryTime() is less than the current time then the timer will expire after the tick count has overflowed and wrapped back to 0. Overflows are handled in the RTOS implementation itself, so a timer's callback function will execute at the correct time whether it is before or after the tick count overflows.

Parameters:

  • xTimer

    The timer being queried.

Returns:

  • If the timer referenced by xTimer is active, then the time at which the timer will next expire is returned (which may be after the current tick count has overflowed, see the notes above).

  • If the timer referenced by xTimer is not active then the return value is undefined.

Example usage:

1static void prvAFunction( TimerHandle_t xTimer )
2{
3TickType_t xRemainingTime;
4
5 /* Calculate the time that remains before the timer referenced by xTimer
6 expires. TickType_t is an unsigned type, so the subtraction will result in
7 the correct answer even if the timer will not expire until after the tick
8 count has overflowed. */
9 xRemainingTime = xTimerGetExpiryTime( xTimer ) - xTaskGetTickCount();
10}