RtSetTimerRelative

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

Syntax

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

Parameters

hTimer

An eRTOS-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

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

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 timer interrupt boundaries. The timer interval will be rounded up to the eRTOS HAL timer resolution. The highest timer resolution is 1 ms.

The behavior of the pInterval parameter is as follows: If you set the timer interval to less than the HAL timer period, eRTOS will set the interval equal to the HAL timer period. The timer 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, eRTOS 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), eRTOS will use the HAL timer period as the eRTOS 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 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: