RtSetTimer

RtSetTimer sets the expiration time and repeat interval on the specified timer.

Syntax

Copy
BOOL RtSetTimer(
    HANDLE hTimer,
    PLARGE_INTEGER pExpiration,
    PLARGE_INTEGER pInterval
);

Parameters

hTimer

A handle to the timer.

pExpiration

A pointer to a LARGE_INTEGER structure indicating the absolute time for the initial expiration of the timer. The clock is specified in 100ns units. If the value of the expiration time is less than zero, the call is interpreted as a request to set the timer relative to current time on the associated clock. The result is identical to calling RtSetTimerRelative, with the absolute value of the specified expiration time.

pInterval

A pointer to a LARGE_INTEGER structure indicating the amount of time between the first expiration and each successive expiration. The clock is specified in 100ns units. See the comments section of RtSetTimerRelative for an explanation of pInterval behavior.

Return Value

If the function succeeds, it returns TRUE. If invalid parameters are specified, it returns FALSE.

Remarks

RtSetTimer sets the expiration time and repeat interval for the specified timer. If the repeat interval is non-zero, then after the first expiration, the timer will repeatedly expire at the specified interval. If the repeat interval pointer is NULL, then the timer will expire only once, i.e., it is a "one-shot" timer. Likewise, a non-NULL interval pointer may be passed in, with its value set to zero, for a one-shot timer.

Upon each expiration of the timer, the handling thread is signaled to indicate the expiration, and the specified handling routine is run. The timer signals expiration only on the timer interrupt boundaries. The timer interval will be rounded up to the eRTOS HAL timer resolution. The lowest HAL timer period is 1 microsecond which provides the highest resolution.

To reset the expiration of a timer that has been previously set, the user must ensure that the timer is not active. That is, it must be either a one-shot timer that has expired, or the user must first cancel the timer with RtCancelTimer.

Note: If your timer period is close to eRTOS kernel’s HAL timer period, the overhead of kernel tick processing may cause a much larger response latency of your timer handling routine (IST). In this case, you should configure a much smaller HAL timer period. For example, if your timer period is 100 us, you should configure HAL period to a smaller value, such as 50 us, depending on your processor frequency.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

Rtapi.h rtkrnl.lib

See Also: