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 dsPIC33/PIC24 devices.
Please consult the note at the beginning of the “Programmable Gain Amplifier(PGA)” chapter in the current 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 Programmable Gain Amplifier (PGA) is essentially a non-inverting amplifier with userprogrammable gains. The output of the PGA can be connected to a number of dedicated
Sample-and-Hold (S&H) inputs of the Analog-to-Digital Converter (ADC) and/or to the high-speed
analog comparator module. The PGA has five selectable gains and may be used as a ground
referenced amplifier (single-ended) or as an amplifier with an independent ground reference.
The major features of the PGA are as follows:
• Selectable operation: single-ended with internal ground or operation with independent
ground reference
• Selectable gains: 4x, 8x, 16x, 32x and 64x
• High gain bandwidth product (40 MHz)
• Rail-to-rail output voltage
• Wide input voltage range (AV
A simplified block diagram of the PGA module is shown in Figure 1-1.
SS – 0.3, AVDD + 0.3)
Figure 1-1:PGAx Module Block Diagram
DS70005146B-page 2 2014-2015 Microchip Technology Inc.
Programmable Gain Amplifier (PGA)
2.0 CONTROL REGISTERS
Note:Each dsPIC33/PIC24 family device variant may have one or more PGA modules.
An ‘x’ used in the names of pins, control/status bits and registers denotes the
particular PGA module number. Refer to the “Programmable Gain Amplifier(PGA)” chapter of the specific device data sheet for more details.
This section outlines the specific functions of each register that controls the operation of the PGA
module. The registers are as follows:
111 = Reserved
110 = Gain of 64x
101 = Gain of 32x
100 = Gain of 16x
011 = Gain of 8x
010 = Gain of 4x
001 = Reserved
000 = Reserved
DS70005146B-page 4 2014-2015 Microchip Technology Inc.
Programmable Gain Amplifier (PGA)
Register 2-2:PGAxCAL: PGAx Calibration Register
U-0U-0U-0U-0U-0U-0U-0U-0
————————
bit 15bit 8
U-0U-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
——PGACAL<5:0>
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 15-6Unimplemented: Read as ‘0’
bit 5-0PGACAL<5:0>: PGAx Offset Calibration bits
The calibration values for the PGA1 and PGA2 bits have to be copied from Flash addresses, 0x800E48
and 0x800E4C, respectively, before the module is enabled. For more information, refer to the Calibration
Data Address table in the “Special Features” chapter in the specific device data sheet.
The Programmable Gain Amplifiers are used as voltage amplifiers; for example, amplification of
voltage across burden resistors or shunt resistors for current sensing. The Programmable Gain
Amplifiers’ output voltage can be read by any of the dedicated Sample-and-Hold circuits on the
ADC module. The PGA’s output voltage may also be used as the input to the comparator module
for overcurrent/voltage protection.
3.2Basic Operation
The PGAx module is enabled by setting the PGAEN (PGAxCON<15>) bit to one. When the
module is disabled (PGAEN = 0), the output is placed in a high-impedance state.
The gain of the PGAx module is selectable through the GAIN<2:0> bits in the PGAxCON register.
There are five selectable gains, ranging from 4x to 64x. The SELPI<2:0> and SELNI<2:0> bits
in the PGAxCON register select one of four positive or negative inputs to the PGAx module.
For single-ended applications, the SELNI<2:0> bits will select the ground as the negative input
source. To provide an independent ground reference, the PGAxN2 and PGAxN3 pins are
available as the negative input source to the PGAx module.
The output voltage of the PGAx module can be connected to the DACOUTx pin by setting the
PGAOEN bit in the PGAxCON register. When the PGAOEN bit is enabled, the output voltage of
PGA1 is connected to DACOUT1 and PGA2 is connected to DACOUT2. For devices with a
single DACOUT pin, the output voltage of PGA2 can be connected to DACOUT1 by configuring
the DBCC bit (FDEVOPT<6>) in the Configuration register. If both the DAC output voltage and
PGA output voltage are connected to the DACOUT pin, the resulting output voltage would be a
combination of the two signals. There is no assigned priority between the PGAx module and the
DACx module.
To achieve the desired offset voltage specifications, calibration values are fed into the PGAxCAL
register. This calibration data is stored in program memory (Flash).
DS70005146B-page 6 2014-2015 Microchip Technology Inc.
Programmable Gain Amplifier (PGA)
Note 1:x = 1 and 2.
2:DACOUTx pin is not available on all devices, refer to the specific device data sheet for more information.
3:PGAxN3 pin is not available on all devices, refer to the specific device data sheet for more information.
–
+
PGAxP1
(1)
PGAxP2
(1)
PGAxP3
(1)
PGAxP4
(1)
SELPI<2:0>
SELNI<2:0>
GND
PGAxN2
(1)
PGAxN3
(1,3)
GND
ADC
S&H
PGAxCON
(1)
PGAxCAL
(1)
PGAEN GAIN<2:0>
PGACAL<5:0>
+
–
DACx
SHxALT<1:0>
(ADALT)
ALTINP
(CMPCONx)
To DACOUTx Pin
(2)
PGAx
(1)
PGAOEN
CMP
PGA1CONbits.PGAEN = 0;//Disable PGA1
PGA1CONbits.SELPI = 0;//PGA1P1 as positive input
PGA1CONbits.SELNI = 1;//PGA1N2 as negative input
PGA1CONbits.GAIN = 3;//8x PGA Gain
PGA1CONbits.PGAEN = 1;//Enable PGA1
PGA1CONbits.PGAEN = 0;//Disable PGA1
PGA1CONbits.SELPI = 0;//PGA1P1 as positive input
PGA1CONbits.SELNI = 0;//Negative input is grounded
PGA1CONbits.GAIN = 2;//4x PGA Gain
PGA1CONbits.PGAEN = 1;//Enable PGA1
Example 3-1:Configuring PGA with Independent Ground Reference
Example 3-2 provides a code sequence to set up the PGA1 module in Single-Ended mode.
Example 3-2:Configuring PGA In Single-Ended Mode
dsPIC33/PIC24 Family Reference Manual
I
IN
I
L1
I
D1
I
Load
I
c
I
S1
I
L2
I
D2
I
S2
ADC
S&H
PGA1
+
–
PFC Output
PWM1
PWM2
+
–
PGA2
ADC
S&H
90V-265V
Rectifier
Figure 3-2 illustrates an example of an SMPS application using the PGA module. In this example,
the PGA amplifies the current through the shunt resistors, with the output of the PGA connected
directly to the ADC module and the PGA configured in Single-Ended mode.
Figure 3-2:PGA Application in Interleaved PFC
DS70005146B-page 8 2014-2015 Microchip Technology Inc.
Legend: — = unimplemented, read as ‘0’. Reset values are shown in hexadecimal.
——————————PGACAL<5:0>0000
—————GAIN2GAIN1GAIN00000
All
Resets
dsPIC33/PIC24 Family Reference Manual
dsPIC33/PIC24 Family Reference Manual
5.0RELATED APPLICATION NOTES
This section lists application notes that are related to this section of the manual. These
application notes may not be written specifically for the dsPIC33/PIC24 device families, but the
concepts are pertinent and could be used with modification and possible limitations. The current
application notes related to the PGA module are:
TitleApplication Note #
No related application notes are available at this time.N/A
Note:Please visit the Microchip web site (www.microchip.com) for additional application
notes and code examples for the dsPIC33/PIC24 families of devices.
DS70005146B-page 10 2014-2015 Microchip Technology Inc.
Programmable Gain Amplifier (PGA)
6.0 REVISION HISTORY
Revision A (March 2014)
This is the initial released version of this document.
Revision B (March 2015)
Removes all references to differential operation throughout the document. These are replaced
with “operation with independent ground reference” or “independent ground reference”,
depending on context.
Resizes Figure 1-1 to place it with the introductory discussion on page 2; the diagram is
otherwise unchanged.
DS70005146B-page 12 2014-2015 Microchip Technology Inc.
Note the following details of the code protection feature on Microchip devices:
YSTEM
CERTIFIED BY DNV
== ISO/TS 16949==
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•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.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC,
FlashFlex, flexPWR, JukeBlox, K
LANCheck, MediaLB, MOST, MOST logo, MPLAB,
OptoLyzer, PIC, PICSTART, PIC
SST, SST Logo, SuperFlash and UNI/O are registered
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
The Embedded Control Solutions Company and mTouch are
registered trademarks of Microchip Technology Incorporated
in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo,
CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, In-Circuit
Serial Programming, ICSP, Inter-Chip Connectivity, KleerNet,
KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo,
MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code
Generation, PICDEM, PICDEM.net, PICkit, PICtail,
RightTouch logo, REAL ICE, SQI, Serial Quad I/O, Total
Endurance, TSHARC, USBCheck, VariSense, ViewSpan,
WiperLock, Wireless DNA, and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
Silicon Storage Technology is a registered trademark of
Microchip Technology Inc. in other countries.
GestIC is a registered trademarks of Microchip Technology
Germany II GmbH & Co. KG, a subsidiary of Microchip
Technology Inc., in other countries.
All other trademarks mentioned herein are property of their
respective companies.
Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC
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.
®
MCUs and dsPIC® DSCs, KEELOQ
®
code hopping
Worldwide Sales and Service
AMERICAS
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://www.microchip.com/
support
Web Address:
www.microchip.com
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Austin, TX
Tel: 512-257-3370
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088