
Mini57
Apr. 06, 2017
Page 211 of 475
Rev.1.00
MINI5
7
S
E
RI
E
S
TECH
NIC
A
L R
E
F
E
RE
N
CE
MA
N
UA
L
6.7.5
Operation of Input Capture Timer/Counter
The Input Capture Timer/Counter unit consists of 2 main functional blocks, Capture block and
Operation block. There are 3 Input Capture units in Capture block for 3 input channel.
The capture units function as detecting and measuring the pulse width and the period of a square
wave. The input channel 0 to 2 have their own edge detectors, which are in Input Capture block
but share with one capture timer/counter, ECAP_CNT, which is in Operation block. The edge
trigger option is programmable through CAPEDG (ECAP_CTL1[5,4], [3,2], [1,0]) register
supporting positive edge, negative edge and both edge triggers. Each capture unit consists of an
enable control bit, IC0EN ~ IC2EN (ECAP_CTL0[6:4]) to enable/disable each input channel and a
status bit CAP0 ~ CAP2 (ECAP_STATUS[10:8]) to let software monitor the current status of each
channel.
The Input Capture supports reload mode and compare mode. For both mode, the capture counter
(ECAP_CNT) serves as a 24-bit up-counting counter whose clock comes from the output of the
clock divider and is gated with CPTST, and the clock source of the clock divider, which can be set
by CAPDIV[2:0] to divide clock by 1,4,16,32,64,96,112 and 128, is programmable (by setting
CNTSRC[1:0]) to be from system clock source, ECAP_CLK or input channel CAP0 ~ CAP2. In
reload mode, ECAP_CNTCMP serves as a reload register while in compare mode
ECAP_CNTCMP serves as a compare register. The Input Capture Timer/Counter Enable bit
(CAPEN) must be set to enable Input Capture Timer/Counter functions. More details of operation
are described in the following.
6.7.5.1
Capture Function
When the capture input detects a valid edge change, it triggers a valid capture event (CAPTE0~2)
so that the content of the free running 24-bit capture counter ECAP_CNT will be
captured/transferred into the capture hold registers, ECAP_HLD0~2 depending on which channel
is triggered. This event also causes the corresponding flag CAPTFx(ECAP_STS[2:0]) to be set,
which will generate an interrupt if the corresponding interrupt enable bit CAPTFxIEN
(ECAP_CTL0[18:16]) is set. Triggered Flags are set by hardware and should be cleared by
software. Software can read the register ECAP_STS to get the status of flags and has to write 1
to the corresponding bit(s) of ECAP_STS to clear flag(s).
In addition, setting the CPTCLR(ECAP_CTL0[26]) will allow hardware to reset capture counter
(ECAP_CNT) automatically whenever the event happens.