
161
CHAPTER 8 16-BIT TIMER/EVENT COUNTERS 00, 01
User
’
s Manual U14260EJ3V1UD
8.4.2 External event counter operation
Setting
The basic operation setting procedure is as follows.
<1> Set the CRC0n register (see
Figure 8-19
for the set value).
<2> Set the count clock by using the PRM0n register.
<3> Set any value to the CR00n register (0000H cannot be set).
<4> Set the TMC0n register to start the operation (see
Figure 8-19
for the set value).
Remarks 1.
For the setting of the TI00n pin, see
8.3 (5) Port mode register 7 (PM7)
.
2.
For how to enable the INTTM00n interrupt, see
CHAPTER 19 INTERRUPT FUNCTIONS
.
The external event counter counts the number of external clock pulses to be input to the TI00n pin with using 16-
bit timer counter 0n (TM0n).
TM0n is incremented each time the valid edge specified by prescaler mode register 0n (PRM0n) is input.
When the TM0n count value matches the 16-bit timer capture/compare register 00n (CR00n) value, TM0n is cleared
to 0 and the interrupt request signal (INTTM00n) is generated.
Input a value other than 0000H to CR00n (a count operation with a pulse cannot be carried out).
The rising edge, the falling edge, or both edges can be selected using bits 4 and 5 (ES00n and ES01n) of prescaler
mode register 0n (PRM0n).
Because an operation is carried out only when the valid level of the TI00n pin is detected twice after sampling with
the internal clock (f
X
/2
3
), noise with a short pulse width can be eliminated.
Caution
When used as an external event counter, the P70/TI000/TO00 or P75/TI001/TO01/BUZ pin cannot
be used as a timer output (TO00, TO01).
Figure 8-19. Control Register Settings in External Event Counter Mode (with Rising Edge Specified)
(a) 16-bit timer mode control register 0n (TMC0n)
(b) Capture/compare control register 0n (CRC0n)
(c) Prescaler mode register 0n (PRM0n)
Remark
0/1: Setting 0 or 1 allows another function to be used simultaneously with the external event counter.
See the description of the respective control registers for details.
n = 0, 1
7
0
6
0
5
0
4
0
TMC0n3
1
TMC0n2
1
1
0
OVF0n
0
TMC0n
Clears and starts on match between TM0n and CR00n.
7
0
6
0
5
0
4
0
3
0
CRC02n
0/1
CRC01n
0/1
CRC00n
0
CRC0n
CR00n used as compare register
ES11n
0/1
ES10n
0/1
ES01n
0
ES00n
1
3
0
2
0
PRM01n
1
PRM00n
1
PRM0n
Selects external clock.
Specifies rising edge for pulse width detection.
Setting invalid (setting
“
10
”
is prohibited.)