
NUC126
Aug. 08, 2018
Page
447
of 943
Rev 1.03
NUC12
6 S
E
RI
E
S
T
E
CH
NI
CA
L R
E
F
E
RE
NCE
MA
NUA
L
0
1
16-bits PWM
up/down counter
CNT
(PWM_CNT0[15:0])
DIRF
(PWM_CNT0[16])
PERIOD
(PWM_PERIOD0)
RCAPPAT
(PWM_RCAPDAT0[15:0])
FCAPDAT
(PWM_FCAPDAT0[15:0])
CAPEN0
(PWM_CAPCTL[0])
CAPINV0
(PWM_CAPCTL[8])
CAPINEN0
(PWM_CAPINEN[0])
PWMx_CH0
RCRLDEN0
(PWM_CAPCTL[16])
FCRLDEN0
(PWM_CAPCTL[24])
Note:
denotes rising edge detect
denotes falling edge detect
Rising Latch
Falling Latch
Figure 6.13-41 PWMx_CH0 Capture Block Diagram
Figure 6.13-42 illustrates the capture function timing. In this case, the capture counter is set as PWM
down counter type and the PERIOD is set to 8 so that the counter counts in the down direction, from 8
to 0. When detecting a falling edge at the capture input pin, the capture function latches the counter
value to the PWM_FCAPDATn register. When detecting the rising edge, it latches the counter value to
the PWM_RCAPDATn register. In this timing diagram, when the falling edge is detected at the first
time, the capture function will reload the counter value from the PERIOD setting because the
FCRLDENn bit is enabled. But at the second time, the falling edge does not result in a reload because
of the disabled FCRLDENn bit. In this example, the counter also reloads at the rising edge of the
capture input because the RCRLDENn bit is enabled, too.
Moreover, if the case is setup as the up counter type, the counter will reload the value zero and count
up to the value PERIOD.
Figure 6.13-42 also illustrates the timing example for the interrupt and interrupt flag generation. When
the rising edge at channel n is detected, the corresponding CRLIFn (PWM_CAPIF[5:0]) bit is set by
hardware. Similarly, a falling edge detection at channel n causes the corresponding CFLIFn
(PWM_CAPIF[13:8]) bit is set by hardware. CRLIFn and CFLIFn bits can be cleared by software by
writing ‘1’. If the CRLIFn bit is set and the CAPRIENn bit is enabled, the capture function generates an
interrupt. If the CFLIFn bit is set and the CAPFIENn bit is enabled, the interrupt also happens.
A condition which is not shown in this figure is: if the rising latch happens again when the CRLIFn bit is
already set, the Overrun status CRLIFOVn (PWM_CAPSTS[5:0]) bit will be set to 1 by hardware to
indicate the CRLIF flag overrunning. Also, if the falling latch happens again, the same hardware
operation
occurs
for
the
CFLIF
interrupt
flag
and
the
Overrun
status
CFLIFOVn
(PWM_CAPSTS[13:8]).