RtSetHalTimerPeriodCounts

RtSetHalTimerPeriodCounts sets the APIC counts per eRTOS HAL timer period.

Syntax

Copy
bool RtSetHalTimerPeriodCounts(
    ULONG PeriodicCounts
);

Parameters

PeriodicCounts

Specifies a new value for the APIC counts per eRTOS HAL timer period.

Return Value

If the function succeeds, it returns true. Otherwise, it returns false. Call GetLastError for additional error information.

Remarks

RtSetHalTimerPeriodCounts allows you to set a new value for the APIC counts per HAL timer period, therefore adjusting the reference frequency of the APIC timer. The HAL timer is used for all other timers or clock-related functions. Adjusting the HAL timer period count will affect the entire system, not just the calling application.

To adjust time, call RtGetHalTimerPeriodCounts to obtain the current APIC counts and the base APIC counts. To adjust time to run slower, increase the APIC counts and call RtSetHalTimerPeriodCounts to set on APIC timer. To adjust time to run faster, decrease the APIC counts and call RtSetHalTimerPeriodCounts to set on APIC timer. The new count can either be calculated by multiplying or dividing a percentage of the current APIC counts, or by incrementing/decrementing certain counts on the current APIC counts.

To avoid significant side effects on timers and timing-relative RTAPIs (processed by HAL ticks), the adjustment of the APIC counts should not be less than 90% or greater than 110% of the base APIC counts. Otherwise, RtSetHalTimerPeriodCounts returns FALSE and GetLastError returns ERROR_INVALID_PARAMETER.

Below is a matrix of the Real-Time APIs that are impacted by adjusting APIC Counts per HAL Timer Period:

Function Process Behavior Change Notes
RtGetClockTime Shifted The returning time is based on HAL ticks.

RtSetTimer

RtSetTimerRelative

Shifted The expiration and interval of timers created by users are based on HAL ticks.

RtSleep / Sleep

RtSleepEx / SleepEx

RtSleepFt / RtSleepFtEx

Shifted The sleeping duration is based on HAL ticks

RtWaitForSingleObject / RtWaitForSingleObjectEx

RtWaitForMultipleObjectsEx

Shifted The waiting timeout is based on HAL ticks.
RtSetThreadTimeQuantum / RtSetThreadTimeQuantumEx Shifted The time quantum is based on HAL ticks.
RtSetFlushTLBTickMod Shifted The mod value is based on HAL ticks.
RtGetThreadTimes No Change The times are based on system time.

RtQueryPerformanceCounter

RtQueryPerformanceFrequency

No Change The times are based on TSC.

Below is a matrix of the eRTOS program samples that are impacted by adjusting APIC Counts per HAL Timer Period:

Sample Impact
srtm.ertos The number of expiration ticks and latency results are valid.
srtm.exe The results are invalid because of inconsistency between expiration tick interval and RtGetClockTime.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

Rtapi.h rtkrnl.lib

See Also: