Datasheet

78K0/Ix2 CHAPTER 8 8-BIT TIMER/EVENT COUNTER 51
R01UH0010EJ0500 Rev.5.00 331
Feb 28, 2012
8.4.2 Operation as external event counter
The external event counter counts the number of external clock pulses to be input to the TI51 pin by 8-bit timer counter
51 (TM51).
TM51 is incremented each time the valid edge specified by timer clock selection register 51 (TCL51) is input. Either the
rising or falling edge can be selected.
When the TM51 count value matches the value of 8-bit timer compare register 51 (CR51), TM51 is cleared to 0 and an
interrupt request signal (INTTM51) is generated.
Whenever the TM51 value matches the value of CR51, INTTM51 is generated.
Setting
<1> Set each register.
Set the port mode register (PM30)
Note
to 1.
TCL51: Select TI51 pin input edge.
TI51 pin falling edge TCL51 = 00H
TI51 pin rising edge TCL51 = 01H
CR51: Compare value
TMC51: Stop the count operation. (TMC51 = 00000000B)
<2> When TCE51 = 1 is set, the number of pulses input from the TI51 pin is counted.
<3> When the values of TM51 and CR51 match, INTTM51 is generated (TM51 is cleared to 00H).
<4> After these settings, INTTM51 is generated each time the values of TM51 and CR51 match.
Note 78K0/IY2: PM34
78K0/IA2, 78K0/IB2 (32 pins): PM34 or PM00
78K0/IB2 (30 pins): PM30
Remark For how to enable the INTTM51 signal interrupt, refer to CHAPTER 18 INTERRUPT FUNCTIONS.
Figure 8-10. External Event Counter Operation Timing (with Rising Edge Specified)
TI51
TM51 count value
CR51
INTTM51
00H 01H 02H 03H 04H 05H N 1 N 00H 01H 02H 03H
N
Count start
Remark N = 00H to FFH