RTX and Windows Clock Accuracy (UP PIC Systems Only)
The interval timer hardware (8254 based) on standard PCs cannot be programmed to run at an even division of seconds (the fundamental interval period is 838.095344 nanoseconds). This means that the actual timer period is always somewhat different from the specified HAL extension timer period (the Hal_Timer_Period setting in the RTX Properties Control Panel).
In addition, the interval timer is used to update the clock and every interval tick adds a fixed time increment to the clock. Windows maintains an internal time increment resolution of 0.1 microseconds, which leads to an accumulation of rounding errors and results in a small clock drift relative to the "true" time-of-day. Because of this drift, Windows periodically reads the CMOS time-of-day clock on the PC and applies a drift correction.
The RTX CLOCK_2 also has drift, but at a different rate from the Windows clocks. The RTX clock is designed to run at a rate that maintains synchronization with the specified timer period (that is, the timer is known to expire at fixed clock times). This allows a straightforward calculation of timer expiration values and timer response latencies.
The table that follows provides the actual timer periods and associated clock drift rates for the each of the possible timer periods.
Specified Timer Period |
Actual Timer Period |
Windows Clock Drift |
RTX Clock Drift |
100 µs |
99.733346 µs |
0.033346 % |
0.26666 % |
200 µs |
200.304787 µs |
0.002394 % |
-0.15239 % |
500 µs |
499.504825 µs |
0.000965 % |
0.09903 % |
1000 µs |
1003.200127 µs |
0.000013 % |
-0.32001 % |
The HAL extension timer is based on the Local APIC timer in APIC systems, instead of the Programmable Timer in PIC systems. As a result, the drift mentioned above does not exist for both CLOCK_2 and CLOCK_3 in UP APIC and MP systems.. |
In comparison with CLOCK_2, CLOCK_3 uses a much more accurate period to set and deliver the clock values, and to calculate the expiration values and response latencies of timers. Therefore, the drift mentioned above no longer exists in CLOCK_3.
General Programming Considerations: The RTX clock should not be used as a time-of-day clock, unless the application is aware of these drift issues.