
XC161 Derivatives
Peripheral Units (Vol. 2 of 2)
Capture/Compare Units
User’s Manual
17-19
V2.2, 2004-01
CC12_X1, V2.1
Figure 17-7
Compare Mode 2 and 3 Block Diagram
Note: The port latch and signal remain unaffected in compare mode 2.
illustrates a few timing examples for compare modes 2 and 3.
In all examples, the reload value of the used timer is set to FFF9
H
. When the timer
overflows, it starts counting from this value upwards.
In Case 1, register CCy contains the value FFFC
H
. When the timer reaches this value,
a match is detected, and the interrupt request line CCyIRQ is activated. In compare
mode 2, this is all that will happen. In compare mode 3, additionally the associated port
output is set to 1. The timer continues to count, and finally reaches its overflow. At this
point, the port output is reset to 0 again. Note that, although not shown in the diagrams,
the overflow signal of the timer also activates the associated interrupt request line
TxIRQ. If the contents of register CCy are not changed, the port output will be set again
during the following timer period, and reset again when the timer overflows. This
operation is ideal for the generation of a pulse width modulated (PWM) signal with a
minimum of software overhead. The pulse width is varied by changing the compare
value accordingly.
In Case 2, the compare operation is blocked after the first match within a timer period.
After the first match at FFFC
H
, the interrupt request is generated and the port output is
set. In addition, further compare matches are disabled. If now a new compare value is
written to register CCy, no interrupt request and no port output influence will take place,
although the new compare value is higher than the current timer contents. Only after the
overflow of the timer, the compare logic is enabled again, and the next match will be
MCB05423
MUX
MUX
Timer T0/T7
ACCy
ACCy
Mode &
Output Ctrl.
CCyIRQ
to Port
Logic
Timer T1/T8
Mode
Control
SEMy
SEEy
Compare
Register CCy
Comparator
= ?
MODy
T0IRQ,
T7IRQ
T1IRQ,
T8IRQ
Mode 3 only!