
CHAPTER 8 8-BIT TIMER/EVENT COUNTERS 2 TO 5
User’s Manual U15905EJ2V1UD
248
8.4.2
Operation as external event counter (8 bits)
The external event counter counts the number of clock pulses input to the TIn pin from an external source by using
8-bit timer counter n (TMn).
Each time the valid edge specified by timer clock selection register n (TCLn) is input to the TIn pin, the TMn
register is incremented. Either the rising edge or the falling edge can be specified as the valid edge.
When the count value of the TMn register matches the value of 8-bit timer compare register n (CRn), the TMn
register is cleared to 0 and an interrupt request signal (INTTMn) is generated.
Setting method
<1>
Set each register.
TCLn register: Selects the TIn input edge.
Falling edge of TIn pin
→ TLCn = 00H
Rising edge of TIn pin
→ TCLn = 01H
CRn register: Compare value (N)
TMCn register: Stops count operation, selects the mode in which clear & start occurs on a match
between the TMn register and CRn register, disables timer output F/F inversion
operation, and disables timer output.
(TMCn register = 0000xx00B,
×: don’t care)
<2>
When the TMCEn bit of the TMCn register is set to 1, the counter counts the number of pulses input from
TIn.
<3>
When the values of the TMn register and CRn register match, INTTMn is generated (TMn register is
cleared to 00H).
<4>
Then, INTTMn is generated each time the values of the TMn register and CRn register match.
INTTMn is generated when the valid edge of TIn is input N + 1 times: N = 00 to FFH
Caution
During external event counter operation, do not rewrite the value of the CRn register.
Remark
n = 2 to 5
Figure 8-3. Timing of External Event Counter Operation (with Rising Edge Specified)
00H
01H
02H
03H
04H
05H
N 1
N
00H
01H
02H
03H
TIn
CRn
INTTMn
TMCEn
TMn count value
Count start
Remark
n = 2 to 5