Op Amp/Comparator: Highlights
Op Amp/Comparator: Highlights
HIGHLIGHTS
This section of the manual contains the following major topics:
Note: This family reference manual section is meant to serve as a complement to device
data sheets. Depending on the device variant, this manual section may not apply to
all dsPIC33E/PIC24E devices.
Please consult the note at the beginning of the “Comparator” or
“Op Amp/Comparator” chapter in the specific device data sheet to check
whether this document supports the device you are using.
Device data sheets and family reference manual sections are available for
download from the Microchip Worldwide Web site at: http://www.microchip.com
1.0 INTRODUCTION
The dsPIC33E/PIC24E devices have multiple built-in comparators, some of which can also be
configured as op amps, with their output being brought to an external pin for gain/filtering
connections.
As illustrated in Figure 1-1 and Figure 1-3, individual comparator and op amp options are
specified by the module’s Special Function Register (SFR) control bits. These options allow
users to:
• Select the edge for trigger and interrupt generation
• Configure the comparator voltage reference
• Configure the band gap
• Configure output blanking and masking
• Configure as a comparator or op amp
Note 1: This document references both the op amp/comparator and the dedicated
comparator modules for the dsPIC33E/PIC24E family of devices. Refer to the
“Comparator” or “Op Amp/Comparator” chapter in the specific device data
sheet for the availability of these features.
2: Throughout this document, when the comparator is referenced, it applies to both
the dedicated comparator module, as well as the op amp/comparator module when
configured as a comparator.
The op amp/comparator and comparator operating modes are configured through the CMxCON
register. Some of the options include Op Amp or Comparator mode, polarity selection of the
comparator and inverting/non-inverting comparator polarity, as well as input selection options.
An option is also available to use the internal reference voltage that is generated by a resistor
ladder network, which is configured by the Comparator Voltage Reference Control (CVRCON)
register (see Register 2-7 and Register 2-8).
CVREFIN 1 VIN+
+ Blanking Digital
CMPx Function Filter
VIN- –
(see Figure 4-1) (see Figure 4-2)
CxOUT
CxIN1- 00
Output Data/Control
CxIN2- 01
CxIN3- 10
CxIN4- 11
CCH<1:0> (CMxCON<1:0>)
Comparator Voltage
Reference
CVREF
Figure 1-2: Dedicated Comparator Module Block Diagram for Devices with Band Gap Reference Circuit
CREF Comparator 1, 2, 3
(x = 1, 2, 3)
CxIN1+ 0
CVREFIN 1 VIN+
+ Blanking Digital
CMPx Function Filter
VIN- (see Figure 4-1) (see Figure 4-2)
CxIN2- 00 – CxOUT
Output Data/Control
CxIN1- 01
CxIN3- 10
11
CCH<1:0>
VREF+ 11
VREF+ VREF- AVDD AVSS
BGSEL<1:0>
Note: Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device data sheet for the
available comparators.
Op Amp/Comparator 1, 2, 3, 5
CCH<1:0> (CMxCON<1:0>) (x = 1, 2, 3, 5)
CxIN1- 00
CxIN2- 01
CxIN3- 10
Op Amp/Comparator
CXIN4- 11 VIN-
– Blanking Digital CxOUT
CMPx Function Filter
VIN+ Trigger
CxIN1+ 0 (see Figure 4-1) (see Figure 4-2)
+ Output
OA1/AN3 01
OA2/AN0 10
OA3/AN6 11
C4IN1- 00
VIN-
– C4OUT
Blanking Digital
CMP4 Function Filter
VIN+ (see Figure 4-1) (see Figure 4-2) Trigger
C4IN1+ 0 + Output
CVREFIN 1
CREF (CMxCON<4>)
Note: Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device data sheet for the
available comparators.
Note 1: The CVR1CON and CVR2CON registers are present on devices with two DACs.
If a device has only one DAC, then only the CVRCON register is present.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: These bits are not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator”
chapter in the specific device data sheet for availability.
Note 1: These bits are not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator”
chapter in the specific device data sheet for availability.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator” chapter in the
specific device data sheet for availability.
2: Inputs that are selected and not available will be tied to VSS.
3: This input is not available when OPMODE (CMxCON<10>) = 1.
Note 1: This bit not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator” chapter in the
specific device data sheet for availability.
2: Inputs that are selected and not available will be tied to VSS.
3: This input is not available when OPMODE (CMxCON<10>) = 1.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For more information, refer to the “Timer” chapter in the specific device data sheet or the
“dsPIC33E/PIC24E Family Reference Manual”, “Timers” (DS70362).
2: For more information, refer to the “High-Speed PWM” chapter in the specific device data sheet or the
“dsPIC33E/PIC24E Family Reference Manual”, “High-Speed PWM” (DS70645).
3: For more information, refer to the “Oscillator” chapter in the specific device data sheet or the
“dsPIC33E/PIC24E Family Reference Manual”, “Oscillator” (DS70580).
4: This bit setting is not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator”
chapter in the specific device data sheet for availability.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: These bits are not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator”
chapter in the specific device data sheet for availability.
2: This bit overrides the TRIS bit setting.
3: Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device data sheet for
available bit selections.
4: This register is available in devices with a single DAC.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: These bits are not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator”
chapter in the specific device data sheet for availability.
2: This bit overrides the TRISx bit setting.
3: Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device data sheet for available
bit selections.
4: This register is available in devices with two DACs.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: These bits are not available on all devices. Refer to the “Comparator” or “Op Amp/Comparator”
chapter in the specific device data sheet for availability.
2: This bit overrides the TRISx bit setting.
3: Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device data sheet for available
bit selections.
4: This register is available in devices with two DACs.
VIN+ +
Output
VIN- –
Input Offset
VIN-
VIN+
Output
Input offset represents the range of voltage levels within which the comparator trip point can
occur. The output can switch at any point in this offset range. Response time is the minimum time
required for the comparator to recognize a change in input levels.
SELSRCA<3:0>
(CMxMSKSRC<3:0>)
MUX A
MAI Blanking Filter
Blanking
Signals “AND-OR” Function Logic
MAI
MBI ANDI
AND
SELSRCB<3:0> MCI
(CMxMSKSRC<7:4)
MAI HLMS
(CMxMSKCON<15)
MUX B
SELSRCC<3:0>
(CMxMSKSRC<11:8)
CMxMSKCON
MUX C
MCI
Blanking
Signals
TxCLK 1xx
SYNCOx 01x
FP 000
FOSC 001
CFDIV<2:0>
VSS
Legend:
CPIN = Input Capacitance
ILEAKAGE = Leakage Current at the pin due to various junctions
RIC = Interconnect Resistance
RS = Source Impedance
VA = Analog Voltage
RFEEDBACK
R1
CxIN1-
VIN –
CMPx OAxOUT
CxIN1+ (VOAXOUT)
+
VADC
OAx
(to ADC)
ADC
As shown in Figure 6-2, there is a second possible configuration for the op amps, which is
referred to as Configuration B. In this configuration, the op amp is not connected internally to the
ADC. Instead, the op amp output is routed to a separate analog input pin (ANx). On certain
device families, this configuration provides an added benefit of increasing the performance of the
op amps. Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device
data sheet for performance information.
RFEEDBACK
R1
CxIN1-
VIN –
OAxOUT
CMPx
CxIN1+ (VOAXOUT)
+
ANx
ADC
Figure 6-3 illustrates an example of a typical 3-phase motor control application taking advantage
of the op amps. In this example, the op amps sample the current through the shunt resistors, with
the output of the op amps connected directly to the ADC module, representing Configuration A
as previously described in Figure 6-1.
VBUS
PHASE_1_HIGH
PWM PWM PWM
Driver Driver Driver
PHASE_2_HIGH
PHASE_1_LOW
PHASE_2_LOW
R
BUS_HIGH C1IN1-
Op Amp 1 OPMODE
PHASE_1_LOW
C1IN1+
OA1OUT
PHASE_1_HIGH
BUS_LOW
VDD/2 OA1 (to ADC)
R
C2IN1-
Op Amp 2 OPMODE
PHASE_2_LOW
C2IN1+
OA2OUT
PHASE_2_HIGH
C3IN1-
Op Amp 3 OPMODE
BUS_LOW
C3IN1+
OA3OUT
BUS_HIGH
Comparator 4
To
PWM
Fault
CVREFIN
Note 1: These bits are not available on all devices. Refer to the “Comparator” or
“Op Amp/Comparator” chapter in the specific device data sheet for availability.
2: Comparator Voltage Reference Value Selection bits may vary in different
devices depending on the DAC resolution. Refer to the “Comparator” or
“Op Amp/Comparator” chapter in the specific device data sheet for availability.
Figure 7-1: Op Amp/Comparator Voltage Reference Block Diagram for Devices with Two DACs
CVRSS = 1 VREFSEL
VREF+ (CVR1CON<4>) CVRSRC (CVR1CON<10>)
CVR1CON<3:0>
AVDD
CVRSS = 0
CVR3
CVR2
CVR1
CVR0
(CVR1CON<4>) 8R 1
CVREFIN
CVREN
(CVR1CON<7>) R 0
CVRR0 R
(CVR1CON<5>)
R
16-to-1 MUX
16 Steps
CVREF10
R CVR1OE
(CVR1CON<6>)
R
VREFSEL (CVR2CON<10>)
R
0
CVRR1 8R
1
AVSS
CVRSS = 1
VREF+ (CVR2CON<4>) CVRSRC
CVR2CON<3:0>
AVDD
CVR3
CVR2
CVR1
CVR0
CVRSS = 0
(CVR2CON<4>) 8R
CVREN
(CVR2CON<4>) R
R
CVRR0
(CVR2CON<5>) R
16-to-1 MUX
R
16 Steps CVREF20
R CVR2OE
(CVR2CON<6>)
R
R
CVRR1 8R
(CVR2CON<11>)
AVSS
Note: Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device data sheet for the
available voltage reference functionality.
Figure 7-2: Op Amp/Comparator Voltage Reference Block Diagram for Devices with a Single DAC
CVRSS = 1 VREFSEL
VREF+ CVRSRC (CVRCON<10>)
CVRCON<3:0>
AVDD
CVRSS = 0
CVR3
CVR2
CVR1
CVR0
8R 1
CVREFIN
CVREN 0
R
16-to-1 MUX
R
16 Steps CVREF
R CVROE
(CVR1CON<6>)
R
R
CVRR 8R
AVDD
R
AVSS
CVREF20
R
AVSS CVR2OE
(CVRCON<14>)
Note: Refer to the “Comparator” or “Op Amp/Comparator” chapter in the specific device data sheet for the
available voltage reference functionality.
dsPIC33E/PIC24E
External Buffer
CVREF R(1)
Generator + Voltage Reference
Voltage CVREF – Output
Reference
Output
Impedance
Note 1: R is dependent upon the Comparator Voltage Reference Control bits, CVRR<1:0>
(CVRxCON<11,5>), and CVR<3:0> value bits (CVRxCON<3:0>).
Note: Visit the Microchip Web site (www.microchip.com) for additional application notes
and code examples for the dsPIC33E/PIC24E family of devices.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
CERTIFIED BY DNV Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
== ISO/TS 16949 ==
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.