View previous topic :: View next topic |
Author |
Message |
bschriek
Joined: 18 Dec 2007 Posts: 80
|
12F1572, FVR as Vref+ for ADC? |
Posted: Wed Sep 12, 2018 3:17 am |
|
|
12F1572
Can I use the internal FVR as Vref+ for the ADC module?
Datasheet itself and CCS are contradictory.
NO; according the ADC block diagram at page 129 of the 12F1571/2 datasheet.
NO; according 15.1.3 at page 130 of the datasheet.
YES; according Register 15-2 ADCON1 (bit1-0) at page 136 of the datasheet.
YES; according 12F1572.h file of CCS.
SETUP_ADC_PORTS()
#define VSS_FVR 0x03000000 //| Range 0-FVR
But if I try to use the FVR as pos reference the AD result is random and doesn't change if I change the input voltage of the ADC.
Just curious what's right.
PCW compiler 5.080 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Sep 12, 2018 5:11 am |
|
|
quick comments...
Now you've got me curious ! However IF the PIC ADC works fine with VDD being Vref and NOT with FVR as Vref, then I'd say FVR is NOT an option.
hmmm...looking at datasheet...
You should post a small test program though, as you'd have to setup FVR before the ADC, FVR MUST be set to X2 or X4 as the ADC Vref must be 1.8 or higher.
Jay |
|
|
bschriek
Joined: 18 Dec 2007 Posts: 80
|
|
Posted: Wed Sep 12, 2018 6:40 am |
|
|
Sorry, all works fine.
The datasheet is not updated!
I tested with CCS and all 3 settings work fine!
Code: |
setup_vref(VREF_ON|VREF_ADC_2v048|VREF_COMP_DAC_OFF|TEMPERATURE_INDICATOR_ENABLED | TEMPERATURE_RANGE_HIGH);
//setup_adc_ports(sAN2|VSS_VDD);
//setup_adc_ports(sAN2|VSS_FVR);
setup_adc_ports(sAN2|VSS_VREF); |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Sat Sep 15, 2018 1:05 am |
|
|
Yes. ADPREF is actually two bits selecting between three options (one unused), but pages 129 and 130, only seem to know about two of the options. Duh....
Obviously be aware of the limitation that 1.8v is the minimum allowed for Vref+ - Vref-. So your 2.048v setting is OK, but the 1.024v setting would not be. |
|
|
bschriek
Joined: 18 Dec 2007 Posts: 80
|
|
Posted: Mon Sep 17, 2018 12:42 am |
|
|
Ok, thank you for your confirmation.
You are right,
TABLE 26-13 informs you about the minimum voltage span of the Vref input of the ADC module. |
|
|
|