RtSetTimer

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

Syntax

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

Parameters

hTimer

An RTX64-specific 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

TRUE if the function succeeds, FALSE if invalid parameters are specified

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 expirations only on the RTX64 timer interrupt boundaries. The RTX64 timer interval will be rounded up to the RTX64 HAL timer resolution. The lowest HAL timer period is 1 microsecond (set in the RTX64 Properties control panel) 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 Real-time subsystem’s HAL timer period, the overhead of Subsystem 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 20 us, depending on your processor frequency. See the Control Panel for how to modify the Hal timer period.

Requirements

Minimum Supported Version RTX64 2013
Header Rtapi.h
Library RtApi.lib (Windows), Rtx_Rtss.lib (RTSS)

See Also:

RtCancelTimer

RtCreateTimer

RtDeleteTimer

RtGetClockResolution

RtGetClockTime

RtGetClockTimerPeriod

RtGetTimer

RtSetClockTime

RtSetTimerRelative