Specifications
69
3706C–MICRO–2/11
AT89LP3240/6440
Figure 12-9. Timer 2 in Clock-out Mode
13. Compare/Capture Array
The AT89LP3240/6440 includes a four channel Compa re/Ca pture Array (CCA) that performs a
variety of timing operations including input event capture, output compare waveform generation
and pulse width modulation (PWM). Timer 2 serves as the time base for the four 16-bit com-
pare/capture modules. The CCA has the following features:
•Four 16-bit Compare/Capt
ure channels
• Common time base provided by Timer 2
• Selectable external and internal capture events including pin change, timer overflow and
comparator output change
• Symmetric/Asymmetric PWM with selectable polarity
•Multi-phasic PWM outputs
• One interrupt flag per channel with a common interrupt vector
The block diagram of the CCA is given in Figure 13-1. Each channel consists of an
8-bit control
register and a 16-bit data register. The channel registers are not directly accessible. The CCA
address register T2CCA provides an index into the array. The control, data low and data high
bytes of the currently indexed channel are accessed through the T2CCC, T2CCL and T2CCH
registers respectively.
Each channel can be individually configured for capture or compare mode. C
apture mode is the
default setting. During capture mode the current value of the time base is copied into the chan-
nel’s data register when the specified external or internal event occurs. An interrupt flag is set at
the same time and the time base may be optionally cleared. To enable compare mode, the
CCMx bit in the channel’s control register (CCCx) should be set to 1. In compare mode a
n inter-
rupt flag is set and an output pin is optionally toggled when the value of the time base matches
the value of the channel’s data register. The time base may also be optionally cleared on a com-
pare match.
Timer 2 must be running (TR2 = 1) in order to perform captures or compares with the CCA.
However, when TR2 = 0 the external capture events will still s et their associated fl
ags and may
be used as additional external interrupts.
OSC
T2EX PIN
T2 PIN
TR2
TIMER 2
INTERRUPT
RCAP2HRCAP2L
TL2 TH2
C/T2
EXF2
TRANSITION
DETECTOR
EXEN2
÷TPS
÷2
T2OE