
ML51/ML54/ML56
Sep. 01, 2020
Page
403
of 719
Rev 2.00
ML
51
/ML
54
/ML
5
6 S
E
RI
E
S
TECHNI
CA
L
RE
F
E
R
E
NC
E
M
A
NU
A
L
ML51/M
L54
/M
L56
Series
Tec
hnical Reference
Manual
Input Capture Interrupt
CAPF0
CAPF1
CAPF2
TF2
Timer 2 Interrupt
Pre-scalar
F
SYS
RCMP2H
T2DIV[2:0]
(T2MOD[6:4])
RCMP2L
TH2
TL2
TR2
(T2CON.2)
Timer 2 Module
CMPCR
(T2MOD.2)
Clear Timer 2
=
C0H
C0L
Noise
Filter
ENF0
(CAPCON2.4)
or
[00]
[01]
[10]
CAP0LS[1:0]
(CAPCON1[1:0])
CAPEN0
(CAPCON0.4)
CAPF0
Input Capture 0 Module
Input Capture 1 Module
Input Capture 2 Module
CAP0
CAP1
CAP2
Figure 6.5-7 Timer 2 Compare Mode and Input Capture Module Functional Block Diagram
Input Capture Module
6.5.3.4
The input capture module along with Timer 2 implements the input capture function. The input capture
module is configured through CAPCON0~2 registers. The input capture module supports 3-channel
inputs (CAP0, CAP1, and CAP2). Each input channel consists its own noise filter, which is enabled via
setting ENF0~2 (CAPCON2[6:4]). It filters input glitches smaller than four system clock cycles. Input
capture channels has their own independent edge detector but share the unique Timer 2. Each trigger
edge detector is selected individually by setting corresponding bits in CAPCON1. It supports positive
edge capture, negative edge capture, or any edge capture. Each input capture channel has to set its
own enabling bit CAPEN0~2 (CAPCON0[6:4]) before use.
While input capture channel is enabled and the selected edge trigger occurs, the content of the free
running Timer 2 counter, TH2 and TL2, will be captured, transferred, and stored into the capture
registers CnH and CnL. The edge triggering also causes CAPFn (CAPCON0.n) set by hardware. The
interrupt will also generate if the ECAP (EIE0.2) and EA bit are both set. For three input capture flags
share the same interrupt vector, user should check CAPFn to confirm which channel comes the input
capture edge. These flags should be cleared by software.
The bit CAPCR (CAPCON2.3) benefits the implement of period calculation. Setting CAPCR makes the
hardware clear Timer 2 as 0000H automatically after the value of TH2 and TL2 have been captured
after an input capture edge event occurs. It eliminates the routine software overhead of writing 16-bit
counter or an arithmetic subtraction.