Page 1 of 1

ADC Internal Vref 18F66K22

Posted: Sun Aug 31, 2014 8:37 pm
by MarkW
Hi

Using FC V5 and 18F66K22

This micro has 3 internal Vref+ sources for the ADC. Namely, VCC / 2.048 / 4.096
However, the ADC component setup allows for only "VCC/AVDD" and "External Vref"
There is no setting for 2.048 Vref.
I need to be able to have this lower Vref+ setting as my supply to the micro can go down
below 3V3 and still read ADC accurately.

Now this can be controlled in code by C icon and declaring ADCON1 = xxxxx;

Question is, does the component setting override this register manual setting
and is it critical where this ADCON1 setting is done? For example if i set this
in the program beginning will it stick or will the ADC component over write it
later on in the program when the ADC is used?

Out of the datasheet....ADCON1:

bit 5-4 VCFG<1:0>: A/D VREF+ Configuration bits
11 = Internal VREF+ (4.096V)
10 = Internal VREF+ (2.048V)
01 = External VREF+
00 = AVDD

Thanx

Mark

Re: ADC Internal Vref 18F66K22

Posted: Sun Aug 31, 2014 8:54 pm
by kersing
The usual calls to obtains an ADC value (ReadAsByte/Int/String/Voltage) all perform an ADC setup and will overwrite your value. You should be able to use ADC_RAW_Configure_Channel, then set ADCON1 to the required value and obtain samples by calling ADC_RAW_Sample_Channel_Byte/Int. Use ADC_RAW_Disable_Channel to shutdown the ADC component once no longer required (to preserve power). You will need to use ADC_RAW_Configure_Channel (and set ADCON1 yourself) after disabling ADC if you want to use it again.

Re: ADC Internal Vref 18F66K22

Posted: Mon Sep 01, 2014 9:19 am
by MarkW
That did the trick :D
Much appreciated. .....I had idea those functions had something to do
with it.