Hardware Reference
In-Depth Information
The input-capture function can be programmed to latch the main timer value (TCNT)
into the input-capture register on the arrival of an active edge and optionally generate an
interrupt. The input-capture function is often used to measure the period, pulse width, duty
cycle, and phase shift. It can also be used as a time reference and count the events that occur
within an interval. There can be up to eight channels (IC0 to IC7) of input-capture function.
The input-capture function of TIM has several limitations that make it unsuitable for high-
frequency applications and a noisy environment. The ECT module adds a holding register to
each of the four input-capture channels (IC0 to IC3). This enhancement adds the following
capabilities:
Interrupt the CPU after two edges have been captured instead of each edge . This
capability reduces the software overhead.
Ignore the short pulse . This capability enables the user to capture event arrival
time and measure pulse width or period in a noisy environment.
Selective no-overwrite . This capability allows the user to do measurements in very high
frequency and not miss the true events because the CPU is busy with other chores.
There can be up to eight output-compare channels (OC0 to OC7). Each output-compare
channel has a 16-bit register, a 16-bit comparator, and an output-compare action pin. The output-
compare function is often used to create a time delay, to generate a waveform, to activate an
operation at a predetermined future time, and so on. To use the output-compare function, one
makes a copy of the main timer, adds a delay to this copy, and stores the sum into an output-
compare register. The 16-bit comparator compares the contents of the main timer with that of
the output-compare register. When they are equal, the corresponding timer flag will be set and
an optional action on the associated signal pin will be triggered: pull to high, pull to low, or
toggle. An output-compare operation can be forced to take effect immediately by writing a 1 into
the corresponding bit in the FORC register. This action will not set the timer flag and will not
generate an interrupt either.
The output-compare channel 7 can control up to eight output-compare channels at the
same time. This capability allows the user to use two output-compare channels to control the
same signal pin.
The TIM module has a 16-bit pulse-accumulator module (PACA). The PACA function has
two operation modes: event counting and gated time accumulation . This function has been
used to generate an interrupt after N events have occurred, measure the frequency of a signal,
count events, measure the pulse width, and so on.
The ECT module adds four buffered 8-bit pulse accumulators. Each pulse accumulator has
an 8-bit counter that will increment when an active edge arrives. Each pair of the pulse accu-
mulators can be concatenated into a 16-bit pulse accumulator.
A set of delay functions are created and stored in the files delay.asm and delay.c and can
be called by the end user. These functions utilize the modulus down counter to generate time
delays.
Using the output-compare function to generate digital waveforms requires frequent atten-
tion from the CPU. This reduces the CPU time available for other applications. The pulse-width
modulation (PWM) is designed to reduce the CPU load from waveform generation. The HCS12
provides eight channels of 8-bit PWM modules. The clock source, prescale factor, the polar-
ity, the waveform alignment, the duty cycle, and the period of the waveform are all program-
mable. Two adjacent 8-bit PWM channels can be concatenated into one 16-bit PWM channel.
The PWM function is used in motor control, light dimming, and any application that requires
the control of the average voltage level.
Search WWH ::




Custom Search