Module pit

Source
Expand description

Support for legacy 8253-compatible timer.

This module implements support for the 8253 programmable interrupt timer, aka the “PIT”. This device provides a source of periodic interrupts that can be used for timing purposes.

The 8253 is rather old and has lots of quirks which are not found in more modern timer circuits. As a result, some amount of jitter/drift is unavoidable when using the PIT. Sadly this is unavoidable due to hardware limitation. For instance, the PIT’s internal frequency is a rational number but not an integer, so all calculations are imprecise due to integer rounding.

This implementation is based on guidance from the following sources:

Structs§

Pit
Timer based on 8253 “PIT” hardware
PitFreq
Frequency of the PIT timer

Constants§

RELOAD_1KHZ
Reload value corresponding to 1 KHz

Functions§

reload_value
Computes a PIT reload value for the given frequency.