
DocID13284 Rev 2
337/564
UM0404
The capture / compare units
As for capture mode, the compare registers are also processed sequentially during compare
mode. When any two compare registers are programmed to the same compare value, their
corresponding interrupt request flags will be set to '1' and the selected output signals will be
generated within eight CPU clock cycles after the allocated timer is incremented to the
compare value.
Further compare events on the same compare value are disabled until the timer is
incremented again or written to by software. After a reset, compare events for register CCx
will only become enabled, if the allocated timer has been incremented or written to by
software and one of the compare modes described in the following has been selected for
this register.
The different compare modes which can be programmed for a given compare register CCx
are selected by the mode control field CCMODx in the associated capture / compare mode
control register. In the following, each of the compare modes, including the special 'double-
register' mode, is discussed in detail.
16.5.1 Compare
mode
0
This is an interrupt-only mode which can be used for software timing purposes. Compare
mode 0 is selected for a given compare register CCx by setting bit-field CCMODx of the
corresponding mode control register to ‘100b’.
In this mode, the interrupt request flag CCxIR is set each time a match is detected between
the content of compare register CCx and the allocated timer.
Several of these compare events are possible within a single timer period, when the
compare value in register CCx is updated during the timer period.
The corresponding port pin CCxIO is not affected by compare events in this mode and can
be used as general purpose I/O pin.
If compare mode 0 is programmed for one of the registers CC8...CC15 or CC24...CC31, the
double-register compare mode becomes enabled for this register if the corresponding bank
1 register is programmed to compare mode 1 (see
).
Table 49. Summary of compare modes
Compare modes
Function
Mode 0
Interrupt-only compare mode;
several compare interrupts per timer period are possible
Mode 1
Pin toggles on each compare match;
several compare events per timer period are possible
Mode 2
Interrupt-only compare mode;
only one compare interrupt per timer period is generated
Mode 3
Pin set ‘1’ on match; pin reset ‘0’ on compare time overflow;
only one compare event per timer period is generated
Double
Register Mode
Two registers operate on one pin; pin toggles on each compare match;
several compare events per timer period are possible.