Hardware Reference
In-Depth Information
There are many applications that require a dedicated timer system, including
•
Time delay creation and measurement
•
Period and pulse-width measurement
•
Frequency measurement
•
Event counting
•
Arrival time comparison
•
Time-of-day tracking
•
Waveform generation
•
Periodic interrupt generation
These applications will be very diffi cult to implement without a dedicated timer system. The
HCS12 implements a very complicated timer system to support the implementation of these
applications.
At the heart of the HCS12 timer system is the 16-bit timer counter (TCNT). This counter
can be started or stopped, as you like. One of the timer functions is called input-capture. The
input-capture function copies the contents of the 16-bit timer to a latch when the specified
event
arrives. An event is represented by a signal edge, which could be a rising or a falling edge.
By capturing the timer value, many measurements can be made. Some of them include
•
Pulse-width measurement
•
Period measurement
•
Duty cycle measurement
•
Event arrival time recording
•
Time reference
Another timer function is called output-compare. The output-compare circuit compares
the 16-bit timer value with that of the output-compare register in each clock cycle and per-
forms the following operations when they are equal:
•
(optionally) Triggers an action on a pin (set to high, set to low, or toggle its signal
level)
•
Sets a flag in a register
•
(optionally) Generates an interrupt request
The output-compare function is often used to generate a time delay, trigger an action at some
future time, and generate a digital waveform. The key to using the output-compare function is
to make a copy of the 16-bit timer, add a delay to it, and store the sum in an
output-compare
register
. The HCS12 has eight output-compare channels, which share the signal pins and regis-
ters with input-capture channels.
The third timer function is the pulse accumulator. This circuit is often used to count the
events arriving in a certain interval or measure the frequency of an unknown signal.
Certain HCS12 members (for example, A family, C family, and H family) implement a
Stan-
dard Timer Module
(TIM) that consists of eight channels of input-capture or output-compare
functions and a 16-bit pulse accumulator, PACA. Other HCS members add additional features
to the TIM module, and the resultant module is referred to as
Enhanced Captured Timer Mod-
ule
(ECT). The design goal of the ECT is to support the requirements of automotive, process
control, and other applications that need additional timer features.
Search WWH ::
Custom Search