245
CHAPTER 10 TIMERS/COUNTERS 2 AND 3
10.7 Basic Operation of Output Control Circuit
The output control circuit controls the timer output pins (TO20, TO21) level by means of match signals from the compare
register (CM20, CM21). The operation of the output control circuit is determined by the timer output control register 2 (TOC2).
As the operation of the TO20 and TO21 output pins, toggle output, PWM output, or PPG output can be selected by using
the timer unit mode register 2 (TUM2).
To output the TO20 and TO21 signals to the pins, the corresponding pins must be set in the control mode by the port
1 mode control register (PMC1).
10.7.1 Basic operation
Setting (1) the ENTO2n (n = 0, 1) bit of the timer output control register 2 (TOC2) enables pulse output from TO2n (n
= 0, 1) pin.
Clearing (0) ENTO2n bit sets the TO2n to a fixed level. The fixed level is determined by the ALV2n (n = 0, 1) bit of the
TOC2. The level is high when ALV2n bit is 0, and low when 1.
10.7.2 Toggle output
Toggle output is an operating mode in which the output level is inverted each time the compare register (CM20/CM21)
value matches with the timer register 2 (TM2) value. The output level of timer output (TO20) is inverted by a match between
CM20 and TM2, and the output level of timer output (TO21) is inverted by a match between CM21 and TM2.
When timer/counter 2 is stopped by clearing (0) the CE2 bit of the timer mode control register 2 (TMC2), the output level
at the time it was stopped is retained.
Figure 10-12. Operation of Toggle Output
ENTO20
TM2
Count Value
0H
FFFFH
Instruction
Execution
CM20 Value
CM21 Value
FFFFH
CM20 Value
CM21 Value
FFFFH
CM20 Value
CM21 Value
FFFFH
CM20 Value
CM21 Value
FFFFH
TO20 Output
(ALV20 = 1)
ENTO21
TO21 Output
(ALV21 = 0)
Instruction Execution
Instruction Execution
Instruction Execution