CHAPTER 11 TIMER 4
293
11.7 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, if a timer/counter is used as an interval timer, the first interval will be shortened by up to one count
clock. The second and subsequent intervals will be as specified.
Figure 11-16. Operation When Count Starts
¨
Interrupt request gener-
ated by timer 4 here
¨
Disables interrupts from timer 4
¨
Clears timer 4 interrupt request flag
(2) There is a possibility of misoperation if the next register contents are rewritten while the timer 4 is running (when
the CE4 bit of the timer mode control register 4 (TMC4) is set). The misoperation occurs as there is no defined order
of priority in the event of contention between the timings at which the hardware function changes due to a register
rewrite and the status changes in the function prior to the rewrite.
When the contents of following registers are rewritten, counter operations must be stopped first to ensure stability.
CLR40 and CLR41 bits of timer mode control register 4 (TMC4)
Prescaler mode register 4 (PRM4)
(3) If the compare register (CM4n: n = 0, 1) and TM4 contents match when an instruction that stops timer register 4
(TM4) operation is executed, the TM4 count operation stops, but an interrupt request is generated.
If you do not want an interrupt to be generated when TM4 operation is stopped, interrupts should be masked by means
of interrupt the mask register before stopping the TM4.
Example
Program in which an interrupt request may be
genera.
Program in which an interrupt request is not generated
CLR1 CE4
OR
OR
CLR1 CE4
CLR1 CMIF40
CLR1 CMIF41
MK1L, #03H
.
.
.
Count Clock
TM4
0
CE4
1
4
2
3
Software count start directive (CE4
←
1)