English
Language : 

PIC18F67J11T-I Datasheet, PDF (323/466 Pages) Microchip Technology – 64/80-Pin, High-Performance, 1-Mbit Flash Microcontrollers
PIC18F87J11 FAMILY
23.5 Comparator Control and
Configuration
Each comparator has up to eight possible combina-
tions of inputs: up to four external analog inputs, and
one of two internal voltage references.
Both comparators allow a selection of the signal from
pin, CxINA, or the voltage from the comparator refer-
ence (CVREF) on the non-inverting channel. This is
compared to either CxINB, CxINC, CxIND or the micro-
controller’s fixed internal reference voltage (VIRV, 1.2V
nominal) on the inverting channel. The comparator
inputs and outputs are tied to fixed I/O pins, defined in
Table 23-1. The available configurations and their
corresponding bit settings are shown in Figure 23-1.
TABLE 23-1: COMPARATOR INPUTS AND
OUTPUTS
Comparator Input or Output
I/O Pin
1
2
Note 1:
C1INA (VIN+)
RF6
C1INB (VIN-)
RF5
C1INC (VIN-)(1)
RH6(1)
C1OUT
RF2
C2INA(VIN+)
RF4
C2INB(VIN-)
RF3
C2INC(VIN-)(1)
RH4(1)
C2IND(VIN-)(1)
RH5(1)
C2OUT
RF1
Available in 80-pin devices only.
23.5.1
COMPARATOR ENABLE AND
INPUT SELECTION
Setting the CON bit of the CMxCON register
(CMxCON<7>) enables the comparator for operation.
Clearing the CON bit disables the comparator resulting
in minimum current consumption.
The CCH<1:0> bits in the CMxCON register
(CMxCON<1:0>) direct either one of three analog input
pins, or the Internal Reference Voltage (VIRV), to the
comparator VIN-. Depending on the comparator operat-
ing mode, either an external or internal voltage
reference may be used. The analog signal present at
VIN- is compared to the signal at VIN+ and the digital
output of the comparator is adjusted accordingly.
The external reference is used when
CREF (CMxCON<2>) = 0 and VIN+ is connected to the
CxINA pin. When external voltage references are used,
the comparator module can be configured to have the
reference sources externally. The reference signal
must be between VSS and VDD, and can be applied to
either pin of the comparator.
The comparator module also allows the selection of an
internally generated voltage reference (CVREF) from
the comparator voltage reference module. This module
is described in more detail in Section 24.0 “Compara-
tor Voltage Reference Module”. The reference from
the comparator voltage reference module is only avail-
able when CREF = 1. In this mode, the internal voltage
reference is applied to the comparator’s VIN+ pin.
Note:
The comparator input pin, selected by
CCH<1:0>, must be configured as an input
by setting both the corresponding TRISF or
TRISH bit, and the corresponding PCFGx
bit in the ANCON1 register.
23.5.1.1 Comparator Configurations in 64-Pin
and 80-Pin Devices
In PIC18F87J11 family devices, the C and D input chan-
nels for both comparators are linked to pins in PORTH
and cannot be reassigned to alternate analog inputs.
Because of this, 64-pin devices offer a total of 4 different
configurations for each comparator. In contrast, 80-pin
devices offer a choice of 6 configurations for
Comparator 1 and 8 configurations for Comparator 2.
The configurations shown in Figure 23-1 are footnoted to
indicate where they are not available.
23.5.2
COMPARATOR ENABLE AND
OUTPUT SELECTION
The comparator outputs are read through the CMSTAT
register. The CMSTAT<0> reads the Comparator 1 out-
put and CMSTAT<1> reads the Comparator 2 output.
These bits are read-only.
The comparator outputs may also be directly output to
the RF1 and RF2 I/O pins by setting the COE bit
(CMxCON<6>). When enabled, multiplexors in the
output path of the pins switch to the output of the com-
parator. The TRISF<2:1> bits still function as the digital
output enable bits for the RF1 and RF2 pins while in
this mode.
By default, the comparator’s output is at logic high
whenever the voltage on VIN+ is greater than on VIN-.
The polarity of the comparator outputs can be inverted
using the CPOL bit (CMxCON<5>).
The uncertainty of each of the comparators is related to
the input offset voltage and the response time given in
the specifications, as discussed in Section 23.2
“Comparator Operation”.
 2007-2012 Microchip Technology Inc.
DS39778E-page 323