275
CHAPTER 10 TIMERS/COUNTERS 2 AND 3
10.9 Cautions
(1) The prescaler uses one time base commonly with all the timers (timers 0 and 1, timers/counters 2 and 3, and timer
4). If one of the timers sets the CE bit to “1”, the time base starts counting. If another timer sets the CE bit to “1”
while one timer operates, the first count clock of the timer may be shortened because the time base has already
started counting.
For example, when using timer/counter 2 as an interval timer, the first interval time is shortened by up to 1 count
clock. The second and those that follow are at the specified interval.
Figure 10-42. Operation When Counting Is Started
¨
Disables interrupt from timer/
counter 2
¨
Clears interrupt request flag for timer/
counter 2
¨
Interrupt request
from timer/counter 2
occurs between
these instructions
.
.
.
.
(2) While timer/counter 2 is operating (while the CE2 bit of the timer mode control register 2 (TMC2) is set),
malfunctioning may occur if the contents of the following registers are rewritten. This is because it is undefined which
takes precedence,–the change in the hardware functions due to rewriting the register, or the change in the status
because of the function before rewriting.
Therefore, be sure to stop the counter operation for the sake of safety before rewriting the contents of the following
registers.
Timer unit mode register 2 (TUM2)
Timer output control register 2 (TOC2)
Prescaler mode register 2 (PRM2)
(3) If the contents of the compare register (CM2n: n = 0, 1) match with those of TM2 when an instruction that stops
timer register 2 (TM2) operation is executed, the counting operation of TM2 stops, but an interrupt request is
generated.
In order not to generate the interrupt when stopping the operation of TM2, mask the interrupt in advance by using
the interrupt mask register before stopping TM2.
Example
Program that may generate interrupt request
Program that does not generate interrupt request
CLR1 CE2
OR
OR
CLR1 CE2
CLR1 CMIF20
CLR1 CMIF21
MK0H, #30H
MK0H, #30H
Count clock
TM2
CE2
Count start Command (CE2
←
1)
by Software
1
0
2
3
4