English
Language : 

UPD784938 Datasheet, PDF (355/733 Pages) NEC – 16-Bit Single-Chip Microcontrollers
CHAPTER 11 TIMER/EVENT COUNTER 2
Figure 11-44. Pulse Width Measurement Setting Procedure
Pulse width measurement
Set CRC2
CRC2 ← 10H
Set INTM0
Set MK0L
; Specify both edges as INTP1 input
valid edges, release interrupt masking
Initialize capture value buffer memory
X0 ← 0
Set TMC1
CE2 ← 1
CMD2 ← 0
; Set 1 in bit 7 of TMC1
Set normal mode (CMD2 = 0)
Enable interrupts
INTP1 interrupt
Figure 11-45. Interrupt Request Servicing that Calculates Pulse Width
INTP1 interrupt
Store capture value in memory
Xn+1 ← CR22
Calculate pulse width
Yn = Xn+1 – Xn
RETI
Preliminary User’s Manual U13987EJ1V0UM00
355