Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ADC reference voltage
22-03-2017, 08:42 PM,
ADC reference voltage
I would like to use a lower reference voltage than 3,3V to get higher resolution for a signal much lower than 3,3V. I have a PIC32MX440F256 and after what I have read AN0 or AN1 can be used as external reference inputs.

However I have not found any information on what command(s) to use to configure one of these inputs as reference input. Does anyone know anything about about this ?

27-03-2017, 11:29 AM,
RE: ADC reference voltage
Did you read this application note ?
It is easier to complain than it is to do, but it is better to do than it is to complain.
28-03-2017, 08:19 AM,
RE: ADC reference voltage
Thanks a lot for the information Regis,

No I have not read that application note before.

But, unfortunately I was a bit unclear (being 70+ and not very well educated in the computer world). I play around with the Pinguino just to try to learn C a little but more.

I have a PIC32 Pinguino Micro with PIC32MX440H256 and what I wanted to know was if there is any command i C on how to change reference voltage ? I have searched a lot but not found anything yet.

Something like "analogReference" in the Arduino world.

28-03-2017, 10:25 AM, (This post was last modified: 28-03-2017, 10:45 AM by regis.)
RE: ADC reference voltage
Hello Urban,
The analogReference() function exists for the 8-bit Pinguino but not yet for the 32-bit.
The voltage reference is controlled by the AD1CON2 register.
Voltage Reference Configuration bits are bits 15-13 VCFG<2:0>.
Possible values are :
          ADC VR+                    ADC VR-
000    AVDD                          AVSS
001    External VREF+ pin    AVSS
010    AVDD                         External VREF- pin
011    External VREF+ pin    External VREF- pin
1xx     AVDD                         AVSS

Note : VR+ =  upper voltage reference
          VR- =  lower voltage reference

PIC18F have internal fixed voltage reference but as far as I know not the PIC32. However I would take a look at the Comparator Voltage Reference register (CVRCON) because this module provides selection for the internal voltage reference. 

Because I don't know if the internal voltage reference can solve your problem, I would apply an external voltage reference on the VREF+ pin and configure the register like that :
AD1CON2bits.VCFG = 0b001;

Now if you think you're confortable enough with C, you can write the analogReference() function for the PIC32 family and send it to me so that I can update the analog.c file.
Syntax and details are described here.

DEFAULT : AD1CON2bits.VCFG = 0b000;

EXTERNAL : AD1CON2bits.VCFG = 0b001;

I'm not sure about this one :
INTERNAL : AD1CON2bits.VCFG = 0b100;
CVRCONbits.CVRR = 0; // 0 or 1
CVRCONbits.CVR = 0; // 0 to 15
See this, chapter 20.3.1 to get more info.
It is easier to complain than it is to do, but it is better to do than it is to complain.
01-04-2017, 07:25 PM,
RE: ADC reference voltage
Hello Regis,

Thanks a lot for all the information concerning analog reference. I have no programmer usable for the PIC32 directly without C, only a homebuilt programmer for PIC12 and 16 controllers.

Unfortunately I think my knowledge in C is far too low to do anything useful with the analogreference command, but perhaps someone else reading this can make a contribution.

I have instead (being an analog man !) used an op.amp to make full use (well almost) of the 0-3.3V range.


Forum Jump:

Users browsing this thread: 1 Guest(s)