Datasheet
PIC18F87K22 FAMILY
DS30009960F-page 358 2009-2018 Microchip Technology Inc.
24.0 COMPARATOR MODULE
The analog comparator module contains three
comparators that can be independently configured in a
variety of ways. The inputs can be selected from the
analog inputs and two Internal Reference Voltages. The
digital outputs are available at the pin level and can
also be read through the control register. Multiple
output and interrupt event generation are also
available. A generic single comparator from the module
is shown in Figure 24-1.
Key features of the module includes:
• Independent comparator control
• Programmable input configuration
• Output to both pin and register levels
• Programmable output polarity
• Independent interrupt generation for each
comparator with configurable interrupt-on-change
24.1 Registers
The CMxCON registers (CM1CON, CM2CON and
CM3CON) select the input and output configuration for
each comparator, as well as the settings for interrupt
generation (see Register 24-1).
The CMSTAT register (Register 24-2) provides the out-
put results of the comparators. The bits in this register
are read-only.
FIGURE 24-1: COMPARATOR SIMPLIFIED BLOCK DIAGRAM
Cx
VIN-
V
IN+
COE
CxOUT
0
1
2
3
0
1
CCH<1:0>
CxINB
CxINC
(2)
C2INB/C2IND
(1,2)
VBG
CxINA
CVREF
CON
Interrupt
Logic
EVPOL<1:0>
CMPxOUT
(CMSTAT<7:5>)
CMPxIF
CPOL
Polarity
Logic
CREF
Note 1: Comparators, 1 and 3, use C2INB as an input to the inverting terminal. Comparator 2 uses C2IND as an input to
the inverted terminal.
2: C1INC, C2INC and C2IND are all unavailable for 64-pin devices (PIC18F6XK22).