2000 Jul 26
117
Philips Semiconductors
Preliminary Specification
Single-chip 8-bit microcontroller with CAN controller
P8xC591
16.1.4
C
APTURE
L
OGIC
The four 16-bit capture registers that Timer T2 is
connected to are: CT0, CT1, CT2, and CT3. These
registers are loaded with the contents of Timer T2, and an
interrupt is requested upon receipt of the input signals
CT0l, CT1I, CT2l, or CT3l. These input signals are shared
with port 1. The four interrupt flags are in the Timer T2
interrupt register (TM2lR special function register). If the
capture facility is not required, these inputs can be
regarded as additional external interrupt inputs (INT2 to
INT5).
Using the capture control register CTCON (see
Section 16.1.4.1), these inputs may capture on a rising
edge, a falling edge, or on either a rising or falling edge.
The inputs are sampled during S1P1 of each cycle. When
a selected edge is detected, the contents of Timer T2 are
captured at the end of the cycle.
16.1.4.1
Table 72
Capture Control Register (address EBH)
Capture Control Register (CTCON)
Table 73
Description of CTCON bits
7
6
5
4
3
2
1
0
CTN3
CTP3
CTN2
CTP2
CTN1
CTP1
CTN0
CTP0
BIT
SYMBOL
DESCRIPTION
7
6
5
4
3
2
1
0
CTN3
CTP3
CTN2
CTP2
CTN1
CTP1
CTN0
CTP0
Capture Register 3 triggered by a falling edge on CT3l.
Capture Register 3 triggered by a rising edge on CT3l.
Capture Register 2 triggered by a falling edge on CT2l.
Capture Register 2 triggered by a rising edge on CT2l.
Capture Register 1 triggered by a falling edge on CT1l.
Capture Register 1 triggered by a rising edge on CT1l.
Capture Register 0 triggered by a falling edge on CT0l.
Capture Register 0 triggered by a rising edge on CT0l.
16.1.5
M
EASURING
T
IME
I
NTERVALS
U
SING
R
EGISTERS
When a recurring external event is represented in the form
of rising or falling edges on one of the four capture pins,
the time between two events can be measured using
Timer T2 and a capture register. When an event occurs,
the contents of Timer T2 are copied into the relevant
capture register and an interrupt request is generated. The
interrupt service routine may then compute the interval
time if it knows the previous contents of Timer T2 when the
last event occurred. With a 6 MHz oscillator, Timer T2 can
be programmed to overflow every 524 ms. When event
interval times are shorter than this, computing the interval
time is simple, and the interrupt service routine is short.
For longer interval times, the Timer T2 extension routine
may be used.
16.1.6
C
OMPARE
L
OGIC
Each time Timer T2 is incremented, the contents of the
three 16-bit compare registers CM0, CM1, and CM2 are
compared with the new counter value of Timer T2. When
amatchisfound, thecorresponding interrupt flagin TM2lR
is set at the end of the following cycle. When a match with
CM0 occurs, the controller sets bits 0-3 of port 3 if the
corresponding bits of the set enable register STE are at
logic 1 (see Section 16.1.6.2).
When a match with CM1 occurs, the controller resets bits
0-3 of port 3 if the corresponding bits of the reset/enable
register RTE are at logic 1 (see Section 16.1.6.1). If RTE
is “0”, then P3.n is not affected by a match between CM1
or CM2 and Timer 2.
Thus, if the current operation is “set,” the next operation
will be “reset” even if the port latch is reset by software
before the “reset” operation occurs. CM0, CM1, and CM2
are reset by the RST signal.
The modified port latch information appears at the port pin
during S5P1 of the cycle following the cycle in which a
match occurred. If the port is modified by software, the
outputs change during S1P1 of the following cycle. Each
port 3 bit (0-3) can be set or reset by software at any time.
A hardware modification resulting from a comparator
match takes precedence over a software modification in
the same cycle. When the comparator results require a
“set” and a “reset” at the same time, the port latch will be
reset.