NEC mPD78F0730 Preliminary User's Manual page 165

8-bit single-chip microcontroller
Table of Contents

Advertisement

(1) Measuring the pulse width by using two input signals of the TI000 and TI010 pins (free-running timer
mode)
Set the free-running timer mode (TMC003 and TMC002 = 01). When the valid edge of the TI000 pin is detected,
the count value of TM00 is captured to CR010. When the valid edge of the TI010 pin is detected, the count value
of TM00 is captured to CR000. Specify detection of both the edges of the TI000 and TI010 pins.
By this measurement method, the previous count value is subtracted from the count value captured by the edge
of each input signal. Therefore, save the previously captured value to a separate register in advance.
If an overflow occurs, the value becomes negative if the previously captured value is simply subtracted from the
current captured value and, therefore, a borrow occurs (bit 0 (CY) of the program status word (PSW) is set to 1).
If this happens, ignore CY and take the calculated value as the pulse width. In addition, clear bit 0 (OVF00) of
16-bit timer mode control register 00 (TMC00) to 0.
(TMC003, TMC002)
Capture trigger input
Capture trigger input
Downloaded from
Elcodis.com
electronic components distributor
CHAPTER 6 16-BIT TIMER/EVENT COUNTER 00
Figure 6-48. Timing Example of Pulse Width Measurement (1)
• TMC00 = 04H, PRM00 = F0H, CRC00 = 05H
FFFFH
TM00 register
A
0000H
Operable bits
00
(TI000)
Capture register
0000H
(CR010)
Capture interrupt
(INTTM010)
(TI010)
Capture register
0000H
(CR000)
Capture interrupt
(INTTM000)
Overflow flag
(OVF00)
M
N
B
01
M
A
B
0 write clear
0 write clear
Preliminary User's Manual U19014EJ1V0UD
P
S
C
D
N
S
C
D
0 write clear
Q
E
Q
P
E
0 write clear
165

Advertisement

Table of Contents
loading

Table of Contents