
M0A21/M0A23 Series
May 06, 2022
Page
362
of 746
Rev 1.02
M0
A21
/M
0
A
2
3
SE
RIES
TEC
H
NICAL
RE
FEREN
C
E
M
ANUAL
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])
PWM_CH0
RCRLDEN0
(PWM_CAPCTL[16])
FCRLDEN0
(PWM_CAPCTL[24])
Note:
denotes rising edge detect
denotes falling edge detect
Rising Latch
Falling Latch
PWM_CH1
Reload signal
Figure 6.10-34 PWM_CH0 Capture Block Diagram
Figure 6.10-35 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.10-35 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 chnnel 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 is enabled, the interrupt also happens.
A condition which is not shown in Figure 6.10-35 is: if the rising latch happens again when the CRLIFn
bit is already set, the Over run 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 Over run status CFLIFOVn (PWM_CAPSTS[13:8]).