CHAPTER 9 8-BIT TIMERS 30 AND 40
User’s Manual U14826EJ5V0UD
105
(2) Operation as external event counter with 16-bit resolution
The external event counter counts the number of external clock pulses input to the TMI/P21 pin by TM30 and
TM40.
To operate as an external event counter with 16-bit resolution, settings must be made in the following
sequence.
<1> Disable operation of TM30 and TM40 (TCE30 = 0, TCE40 = 0).
<2> Disable timer output of TMO (TOE40 = 0)
Note 1
.
<3> Set P21 to input mode (PM21 = 1).
<4> Select the external input clock for timer 40 (see
Tables 9-9
and
9-10
).
<5> Set the operation mode of timer 30 and timer 40 to 16-bit timer counter mode (see
Figures 9-4
and
9-
5
).
<6> Set a count value in CR30 and CR40.
<7> Enable the operation of TM30 and TM40 (TCE40 = 1
Note 2
).
Notes
1.
Timer 40 only
2.
Start and clear of the timer in the 16-bit timer counter mode are controlled by TCE40 (the value
of TCE30 is invalid).
Each time the valid edge is input, the values of TM30 and TM40 are incremented.
When the count values of TM30 and TM40 match the values set in CR30 and CR40 respectively, both TM30
and TM40 are simultaneously cleared to 00H and counting continues. At the same time, an interrupt request
signal (INTTM40) is generated (INTTM30 is not generated).
Figure 9-17 shows the timing of the external event counter operation.
Caution Be sure to stop the timer operation before overwriting the count clock with different data.