Digital timer/counters are used throughout embedded designs to provide a
series of time or count related events within the system with the minimum of
processor and software over-head. Most embedded systems have a time component
within them such as timing references for control sequences, to provide system
ticks for operating systems and even the generation of waveforms for serial
port baud rate generation and audible tones.
They are available in several different types but are essen-tially based
around a simple structure as shown.
The central timing is derived from a clock input. This clock may be
internal to the timer/counter or be external and thus connected via a separate
pin. The clock may be divided using a simple divider which can provide limited
division normally based on a power of two or through a pre-scalar which
effectively scales down or divides the clock by the value that is written into
the pre-scalar register. The divided clock is then passed to a counter which is
normally configured in a count-down operation, i.e. it is loaded with a preset
value which is clocked down towards zero. When a zero count is reached, this
causes an event to occur such as an interrupt of an external line changing
state. The final block is loosely described as an I/O control block but can be
more sophis-ticated than that. It generates interrupts and can control the
counter based on external signals which can gate the count-down and provide
additional control. This expands the functionality that the timer can provide as
will be explained later.
Timer/counters are normally defined in terms of the coun-ter size that
they can provide. They typically come in 8, 16 and 24 bit variants. The bit
size determines two fundamental properties:
The pre-scalar value and hence
the frequency of the slowest clock that can be generated from a given clock
The counter size determines the
maximum value of the counter-derived period and when used with an external
clock, the maximum resolution or measurement of a time-based event.
These two properties often determine the suitability of a device for an