![NEC V850/SC1 Скачать руководство пользователя страница 282](http://html.mh-extra.com/html/nec/v850-sc1/v850-sc1_user-manual_248178282.webp)
CHAPTER 8 TIMER/COUNTER FUNCTION
280
User’s Manual U15109EJ3V0UD
(3) Pulse width measurement with free-running counter and two capture registers
When 16-bit timer register n (TMn) is used as a free-running counter (refer to
Figure 8-14
), the pulse width of the
signal input to the TIn0 pin can be measured.
When the edge specified by bits 4 and 5 (ESn00 and ESn01) of prescaler mode register n0 (PRMn0) is input to
the TIn0 pin, the value of TMn is loaded to 16-bit capture/compare register n1 (CRn1), and an external interrupt
request signal (INTTMn1) is set.
The value of TMn is also loaded to 16-bit capture/compare register n0 (CRn0) when an edge that is the reverse
of the one that triggers capturing to CRn1 is input.
The edge of the TIn0 pin is specified by bits 4 and 5 (ESn00 and ESn01) of prescaler mode register n (PRMn0).
The rising or falling edge can be specified.
The valid edge of TIn0 is detected through sampling at a count clock cycle selected by prescaler mode registers
n0 and n1 (PRMn0, PRMn1), and the capture operation is not performed until the valid level is detected two
times, eliminating noise with a short pulse width.
Caution
If the valid edge of the TIn0 pin is specified to be both the rising and falling edges,
capture/compare register n0 (CRn0) cannot perform a capture operation.
Remark
n = 0, 1, 7 to 12
Figure 8-14. Control Register Settings for Pulse Width Measurement
with Free-Running Counter and Two Capture Registers
(a) 16-bit timer mode control registers 0, 1, 7 to 12 (TMC0, TMC1, TMC7 to TMC12)
TMCn3
TMCn2
TMCn1
OVFn
TMCn
0
0
0
0
0
1
0/1
0
Free-running mode
(b) Capture/compare control registers 0, 1, 7 to 12 (CRC0, CRC1, CRC7 to CRC12)
CRCn2
CRCn1
CRCn0
CRCn
0
0
0
0
0
1
1
1
CRn0 as capture
register
Captures to CRn0 at
edge reverse to valid
edge of TIn0 pin.
CRn1 as capture
register
Remarks 1.
0/1: When these bits are reset to 0 or set to 1, other functions can be used along with the pulse
width measurement function. For details, refer to
8.1.4 (1) 16-bit timer mode control
registers 0, 1, 7 to 12 (TMC0, TMC1, TMC7 to TMC12)
and
(2) Capture/compare control
registers 0, 1, 7 to 12 (CRC0, CRC1, CRC7 to CRC12)
.
2.
n = 0, 1, 7 to 12