PIC18F2420/2520/4420/4520
changed, the comparator output level may not be valid
for the specified mode change delay shown in
20.1 Comparator Configuration
There are eight modes of operation for the compara-
tors, shown in Figure 20-1. Bits CM<2:0> of the
CMCON register are used to select these modes. The
TRISA register controls the data direction of the com-
parator pins for each mode. If the Comparator mode is
Section 26.0 “Electrical Characteristics”.
Note:
Comparator interrupts should be disabled
during Comparator mode change;
otherwise, a false interrupt may occur.
a
FIGURE 20-1:
COMPARATOR I/O OPERATING MODES
Comparators Reset
Comparators Off (POR Default Value)
CM<2:0> = 000
CM<2:0> = 111
A
D
VIN-
VIN-
RA0/AN0
RA0/AN0
Off (Read as ‘0’)
Off (Read as ‘0’)
Off (Read as ‘0’)
Off (Read as ‘0’)
C1
C2
C1
C2
VIN+
VIN+
A
D
RA3/AN3/
VREF+
RA3/AN3/
VREF+
A
D
D
VIN-
VIN-
RA1/AN1
RA1/AN1
VIN+
VIN+
A
RA2/AN2/
VREF-/CVREF
RA2/AN2/
VREF-/CVREF
Two Independent Comparators
Two Independent Comparators with Outputs
CM<2:0> = 010
CM<2:0> = 011
A
A
VIN-
VIN-
RA0/AN0
RA0/AN0
C1OUT
C2OUT
C1OUT
C2OUT
C1
C2
C1
C2
VIN+
RA3/AN3/
VREF+
VIN+
A
A
RA3/AN3/
VREF+
RA4/T0CKI/C1OUT*
A
A
VIN-
RA1/AN1
RA2/AN2/
A
A
VIN-
RA1/AN1
VIN+
RA2/AN2/
VREF-/CVREF
VIN+
VREF-/CVREF
RA5/AN4/SS/HLVDIN/C2OUT*
Two Common Reference Comparators
Two Common Reference Comparators with Outputs
CM<2:0> = 100
CM<2:0> = 101
A
A
VIN-
VIN-
RA0/AN0
RA0/AN0
C1OUT
C2OUT
C1OUT
C1
C2
C1
VIN+
VIN+
A
A
RA3/AN3/
VREF+
RA3/AN3/
VREF+
RA4/T0CKI/C1OUT*
A
D
VIN-
RA1/AN1
RA2/AN2/
A
VIN-
RA1/AN1
VIN+
C2OUT
RA2/AN2/
D
C2
VIN+
VREF-/CVREF
VREF-/CVREF
RA5/AN4/SS/HLVDIN/C2OUT*
Four Inputs Multiplexed to Two Comparators
One Independent Comparator with Output
CM<2:0> = 110
CM<2:0> = 001
A
A
A
VIN-
RA0/AN0
RA0/AN0
CIS = 0
CIS = 1
VIN-
A
C1OUT
C1
RA3/AN3/
VREF+
VIN+
RA3/AN3/
VREF+
C1OUT
C2OUT
C1
C2
VIN+
A
A
RA4/T0CKI/C1OUT*
RA1/AN1
VIN-
CIS = 0
CIS = 1
RA2/AN2/
VREF-/CVREF
VIN+
D
D
VIN-
RA1/AN1
RA2/AN2/
Off (Read as ‘0’)
C2
VIN+
CVREF
From VREF Module
VREF-/CVREF
A = Analog Input, port reads zeros always
D = Digital Input
CIS (CMCON<3>) is the Comparator Input Switch
* Setting the TRISA<5:4> bits will disable the comparator outputs by configuring the pins as inputs.
DS39631E-page 234
© 2008 Microchip Technology Inc.