16-Bit Capture Mode; 16-Bit Software Timer Mode; Pca 16-Bit Capture Mode - Intel MCS 51 User Manual

Table of Contents

Advertisement

i~o
8XC51FXHARDWARE DESCRIPTION
6.3
16-Bit Capture Mode
Bothpositive andnegative t ransitions e antriggera cap-
turewith the
PCA. This gives the PCA the flexibility to
measure perio& pulse widths, duty cycles, and phase
differences on up to five separate inputs. Setting the
CAPPn snd/or CAPNn in the CCAPMn mode register
select the input trigger-positive snd/or negative tran-
sition-for module n. Refer to Figure 17.
The external input pins CEXOthrough CEX4 are sam-
pled for a transition. When a valid transition is detected
(psitive rind/or negativeedge), hardware loads the
16-bit vrdueof the PCA timer (CH, CL) into the mod-
de's capture registers (CCAPnH, CCAPnL). The re-
sulting value in the capture registers reflects the PCA
timer value at the time a transitionwas detected on the
CEXn pin.
Upon a capture, the module's event flag (CCFn) in
CCON is set, and an interrupt is flagged if the ECCFn
bit in the mode regista CCAPMn is set. The PCA in-
terrupt will then be generatedifit is enabled. Since the
hardware does not clear an event tlag when the inter-
rupt is vectored to, the tlag must be cleared in software.
In the interrupt service routine, the lt%it capture value
must be saved in IL4M before the next capture
event
ocours.
A subsequent capture on the same CEXn pin
will write over the first capture value in CCAPnH and
CCAPnL.
6.4
16-Bit Software Timer Mode
In
the eotnpare modej the 16-bitvalue of the PCA tim-
er is compared with a 16-bit value pm-loaded in the
module's compare registers(CCAPnH, CCAPnL). The
comparison oeours three times per machine cycle in
order to recognize the fastest possible clock input (i.e.
~. x oscillator frequency). Setting the ECOMn bit in
the mode register CCAPMn enables the comparator
function as shown in Figure 18.
For the Software Timer mode, the MATn bit also needs
to be set. When a match occurs between the PCA timer
and the compare registen, a match signal is generated
and the module's event flag (CCFn) is set. An interrupt
is then flagged if the ECCFn bit is set. The PCA inter-
rupt is generated ordy if it has been properly enabled.
software must clear the event flag before the next inter-
rupt will be flagged.
——
+-l
1/1
1
I
CEXn
&
PIN
+KJ
I
/1
I
I
I
+-'N"RRUM
z
CH
:
CL
PCA
I
llMER/COUNIER
8
8
CAPTURE
GGl
I
I
I
I
x
I
o
I
o
I
o
ECCFn
n = O, 1, 2, 3 or
4
CCAPMn MOOE REGISTER
x = OOtrt Care
270653-14
Figure 17.
PCA
16-Bit Capture Mode
5-24

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents