Internal VREF in 18F25K22

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
jethronull
Posts: 30
Joined: Tue Dec 04, 2012 4:03 am
Has thanked: 1 time
Contact:

Internal VREF in 18F25K22

Post by jethronull »

I read a couple of posts where people enquired about using the internal vrefs of various PICs and it seemed that it just needs a register appropriately set to take over from the standard ADC macro which is limited to VDD and the external VREF+. I could not find any reference to my PIC (18F25K22) on these forums, so I dug in the datasheet and decided that two registers were affected. I put in what seems like the correct values for 2.048V ref and internal ref enabling:

Code: Select all

vrefcon0 = 11100000;
adcon1 = 00001000;
. On running though it seems Flowcode is still using the VDD or VREF+ options in the ADC macro config. What am I missing here?
Jon/JethroNull

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Internal VREF in 18F25K22

Post by Benj »

Hello,

That looks like it should work fine as long as you have the VREF option set to VDD in the ADC component properties. One problem is that you are not entering the data in binary mode eg 0b00100110. I have changed the values below to hex so these should also work fine.

Code: Select all

vrefcon0 = 0xE0;
adcon1 = 0x08;
You may have to do code like this to get the Vref to stabilise correctly.

Code: Select all

vrefcon0 = 0xA0;
while ((vrefcon0 & 0x40) == 0);
adcon1 = 0x08;

jethronull
Posts: 30
Joined: Tue Dec 04, 2012 4:03 am
Has thanked: 1 time
Contact:

Re: Internal VREF in 18F25K22

Post by jethronull »

Ben,

Perfect, that worked a treat. Duh me. binary without 0b!. But I wouldn't have known to do the while bit for settling.

Thanks a lot.
Jon/JethroNull

Post Reply