Datasheet

PIC16F684
DS41202F-page 58 © 2007 Microchip Technology Inc.
8.2 Comparator Configuration
There are eight modes of operation for the comparator.
The CM<2:0> bits of the CMCON0 register are used to
select these modes as shown in Figure 8-5. I/O lines
change as a function of the mode and are designated
as follows:
Analog function (A): digital input buffer is disabled
Digital function (D): comparator digital output,
overrides port function
Normal port function (I/O): independent of
comparator
The port pins denoted as “A” will read as a ‘0
regardless of the state of the I/O pin or the I/O control
TRIS bit. Pins used as analog inputs should also have
the corresponding TRIS bit set to ‘1’ to disable the
digital output driver. Pins denoted as “D” should have
the corresponding TRIS bit set to0’ to enable the
digital output driver.
FIGURE 8-5: COMPARATOR I/O OPERATING MODES
Note: Comparator interrupts should be disabled
during a Comparator mode change to
prevent unintended interrupts.
C1
C1IN-
VIN-
V
IN+
C1IN+
Off
(1)
Comparators Reset (POR Default Value)
A
A
CM<2:0> = 000
C2
C2IN-
VIN-
V
IN+
C2IN+
Off
(1)
A
A
C1
C1IN-
VIN-
V
IN+
C1IN+
C1OUT
Two Independent Comparators
A
A
CM<2:0> = 100
C2
C2IN-
VIN-
V
IN+
C2IN+
C2OUT
A
A
C1
C1IN-
VIN-
V
IN+
C1IN+
C1OUT
Two Common Reference Comparators
A
I/O
CM<2:0> = 011
C2
C2IN-
VIN-
V
IN+
C2IN+
C2OUT
A
A
C1
C1IN-
VIN-
V
IN+
C1IN+
Off
(1)
One Independent Comparator
I/O
I/O
CM<2:0> = 101
C2
C2IN-
VIN-
V
IN+
C2IN+
C2OUT
A
A
C1
C1IN-
VIN-
V
IN+
C1IN+
Off
(1)
Comparators Off (Lowest Power)
I/O
I/O
CM<2:0> = 111
C2
C2IN-
VIN-
V
IN+
C2IN+
Off
(1)
I/O
I/O
C1
C1IN-
VIN-
V
IN+
C1IN+
C1OUT
Four Inputs Multiplexed to Two Comparators
A
A
CM<2:0> = 010
C2
C2IN-
VIN-
V
IN+
C2IN+
C2OUT
A
A
From CVREF Module
CIS = 0
CIS = 1
CIS = 0
CIS = 1
C1
C1IN-
VIN-
V
IN+
C1OUT(pin)
C1OUT
Two Common Reference Comparators with Outputs
A
D
CM<2:0> = 110
C2
C2IN-
VIN-
V
IN+
C2IN+
C2OUT
A
A
C2OUT(pin)
C1
C1IN-
VIN-
V
IN+
C1IN+
C1OUT
Three Inputs Multiplexed to Two Comparators
A
A
CM<2:0> = 001
C2
C2IN-
VIN-
V
IN+
C2IN+
C2OUT
A
A
CIS = 0
CIS = 1
D
Legend: A = Analog Input, ports always reads ‘0 CIS = Comparator Input Switch (CMCON0<3>)
I/O = Normal port I/O D = Comparator Digital Output
Note 1: Reads as ‘0’, unless CxINV = 1.