ADC Internal Vref 18F66K22

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

ADC Internal Vref 18F66K22

Post 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

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: ADC Internal Vref 18F66K22

Post 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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: ADC Internal Vref 18F66K22

Post by MarkW »

That did the trick :D
Much appreciated. .....I had idea those functions had something to do
with it.

Post Reply