English
Language : 

PIC18FXX8 Datasheet, PDF (252/402 Pages) Microchip Technology – 28/40-Pin High-Performance, Enhanced Flash Microcontrollers with CAN Module
PIC18FXX8
21.1 Comparator Configuration
There are eight modes of operation for the compara-
tors. The CMCON register is used to select these
modes. Figure 21-1 shows the eight possible modes.
The TRISD register controls the data direction of the
comparator pins for each mode. If the Comparator
mode is changed, the comparator output level may not
be valid for the specified mode change delay shown in
Section 27.0 “Electrical Characteristics”.
Note:
Comparator interrupts should be disabled
during a Comparator mode change;
otherwise, a false interrupt may occur.
FIGURE 21-1:
COMPARATOR I/O OPERATING MODES
Comparators Reset (POR Default Value)
CM2:CM0 = 000
Comparators Off
CM2:CM0 = 111
RD1/PSP1 A
RD0/PSP0 A
VIN-
VIN+ C1
Off (Read as ‘0’)
RD1/PSP1 D
RD0/PSP0 D
VIN-
VIN+ C1
Off (Read as ‘0’)
RD3/PSP3 A
RD2/PSP2 A
VIN-
VIN+ C2
Two Independent Comparators
CM2:CM0 = 010
RD1/PSP1 A
RD0/PSP0 A
VIN-
VIN+ C1
RD3/PSP3 A
RD2/PSP2 A
VIN-
VIN+ C2
Off (Read as ‘0’)
C1OUT
C2OUT
Two Common Reference Comparators
CM2:CM0 = 100
RD1/PSP1 A
RD0/PSP0 A
VIN-
VIN+ C1
C1OUT
RD3/PSP3 A
RD2/PSP2 D
VIN-
VIN+ C2
C2OUT
One Independent Comparator with Output
CM2:CM0 = 001
RD1/PSP1 A
RD0/PSP0 A
VIN-
VIN+ C1
C1OUT
RE1/AN6/WR/C1OUT
RD3/PSP3 D
RD2/PSP2 D
VIN-
VIN+ C2
Off (Read as ‘0’)
A = Analog Input, port reads zeros always
D = Digital Input
CIS (CMCON<3>) is the Comparator Input Switch
RD3/PSP3 D
RD2/PSP2 D
VIN-
VIN+ C2
Off (Read as ‘0’)
Two Independent Comparators with Outputs
CM2:CM0 = 011
RD1/PSP1 A
RD0/PSP0 A
VIN-
VIN+ C1
C1OUT
RE1/AN6/WR/C1OUT
RD3/PSP3 A
RD2/PSP2 A
VIN-
VIN+ C2
RE2/AN7/CS/C2OUT
C2OUT
Two Common Reference Comparators with Outputs
CM2:CM0 = 101
RD1/PSP1 A
RD0/PSP0 A
VIN-
VIN+ C1
C1OUT
RE1/AN6/WR/
C1OUT
RD3/PSP3 A
RD2/PSP2 D
VIN-
VIN+ C2
C2OUT
RE2/AN7/CS/C2OUT
Four Inputs Multiplexed to Two Comparators
CM2:CM0 = 110
RD1/PSP1 A
RD0/PSP0 A
CIS = 0
CIS = 1
VIN-
VIN+ C1
RD3/PSP3 A
RD2/PSP2 A
CIS = 0
CIS = 1
VIN-
VIN+ C2
C1OUT
C2OUT
CVREF From VREF Module
DS41159D-page 250
 2004 Microchip Technology Inc.