Timer - Computer Timers

Computer Timers

See also: Programmable Interval Timer and High Precision Event Timer

Computer systems usually have at least one timer. These are typically digital counters that either increment or decrement at a fixed frequency, which is often configurable, and which interrupt the processor when reaching zero, or alternatively a counter with a sufficiently large word size that it will not reach its counter limit before the end of life of the system.

More sophisticated timers may have comparison logic to compare the timer value against a specific value, set by software, that triggers some action when the timer value matches the preset value. This might be used, for example, to measure events or generate pulse width modulated waveforms to control the speed of motors (using a class D digital electronic amplifier).

As the number of hardware timers in a computer system or processor is finite and limited, operating systems and embedded systems often use a single hardware timer to implement an extensible set of software timers. In this scenario, the hardware timer's interrupt service routine would handle house-keeping and management of as many software timers as are required, and the hardware timer would be set to expire when the next software timer is due to expire. At expiry, the interrupt routine would update the hardware timer to expire when the next software timer is due, and any actions would be triggered for the software timers that had just expired. Expired timers that are continuous would also be reset to a new expiry time based on their timer interval, and one-shot timers would be disabled or removed from the set of timers. While simple in concept, care must be taken with software timer implementation if issues such as timer drift and delayed interrupts is to be minimised.

Read more about this topic:  Timer

Famous quotes containing the word computer:

    The archetype of all humans, their ideal image, is the computer, once it has liberated itself from its creator, man. The computer is the essence of the human being. In the computer, man reaches his completion.
    Friedrich Dürrenmatt (1921–1990)