CHAPTER 9 TIMER/COUNTER FUNCTION
229
User’s Manual U15195EJ5V0UD
9.1.6 Operation
Remarks 1.
In the explanation of operations in this section, the bits that affect the TO0n0 to TO0n5 outputs are
assumed to be set as follows.
ALVTO = 1, ALVUB = 0, ALVVB = 0, ALVWB = 0, TORTOn =0
2.
The F/F in this section indicates the flip-flop for controlling the output of the TO0n0 to TO0n5 pins.
(1) Basic operation
Timer 0 (TM0n) is a 16-bit interval timer that operates as an up/down timer or as an up timer. The cycle is
controlled by compare register 0n3 (CM0n3) (n = 0, 1).
All TM0n bits are cleared (0) by RESET input and the count operation is stopped.
Count operation enable/disable is controlled by the TM0CEn bit of timer control register 0n (TMC0n). The
count operation is started by setting the TM0CEn bit to 1 by software. Resetting the TM0CEn bit to 0 clears
TM0n and stops the count operation.
When the value of compare register 0n3 (CM0n3) set beforehand and the value of the TM0n counter match,
a match interrupt (INTCM0n3) is generated.
The count clock to TM0n can be selected from among 6 internal clocks using the TMC0n register. If TM0n
has been set as an up/down timer, an underflow interrupt (INTTM0n) is generated when TM0n becomes
0000H during down counting.
TM0n has the following three operation modes, which are selected using timer control register 0n (TMC0n).
•
PWM mode 0: Triangular wave modulation (right-left symmetric waveform control)
•
PWM mode 1: Triangular wave modulation (right-left asymmetric waveform control)
•
PWM mode 2: Sawtooth wave modulation control