RtSetTimerRelative

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

Syntax

BOOL RtSetTimerRelative(
    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 time for the initial expiration of the timer. Expiration is calculated relative to the current value of the clock associated with the timer at creation. The clock is specified in 100ns units.

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 below for an explanation of pInterval behavior.

Return Value

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

Remarks

RtSetTimerRelative sets the relative 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 highest RTX64 timer resolution is 1 ms, which can be set in the Control Panel.

The behavior of the pInterval parameter is as follows: If you set the RTX64 interval to less than the HAL timer period, RTX64 will set the interval equal to the HAL timer period. The RTX64 interval must be a multiple of the HAL Timer period. If you specify an interval that is not a multiple of the HAL Timer period, RTX64 will force the interval to the closest multiple of the HAL Timer period. Two timers with the same interval as the HAL Timer period will necessarily have the same phase. If you specify an interval that is less than the HAL timer period (default to 100 microseconds), RTX64 will use the HAL timer period as the RTX64 interval instead of the interval you specified.

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: