ADC - error during compile.

Moderator: Benj

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8825
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2561 times
Been thanked: 3718 times
Contact:

ADC - error during compile.

Postby medelec35 » Wed Jan 25, 2012 9:32 pm

Devices affected are:
18F2220, 18F2221, 18F2320, 18F2321, 18F24J10, 18F2410, 18F2420, 18F2423, 18F2450,
18F2455, 18F2480, 18F25J10, 18F2510, 18F2515, 18F2520, 18F2523, 18F2525, 18F2550,
18F2580, 18F2585, 18F2610, 18F2620, 18F2680, 18F4220, 18F4221, 18F4320, 18F4321,
18F44J10, 18F4410, 18F4420, 18F4423, 18F4450, 18F4455, 18F4480, 18F45J10, 18F4510,
18F4515, 18F4520, 18F4523, 18F4525, 18F4550, 18F4580, 18F4585, 18F4610, 18F4620,
18F4680, 18F4682 & 18F4685.

Jonny was the first to post about this:
viewtopic.php?f=29&t=10059&p=31452#p31445

Unfortunately I did not see that post when I posted my fix here:
viewtopic.php?f=29&t=10077#p31579
Fix still worked OK, but not sure if 12 Bit ADC devices will work?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
STibor
Posts: 262
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 115 times
Been thanked: 112 times
Contact:

Re: ADC - error during compile.

Postby STibor » Mon Aug 20, 2012 8:14 am

Pic18f6622 external ADC Vref setting does not work.

I checked the Flowcode4 PIC_ADC_12.c file included in the following line:

Code: Select all

/ / assign VREF Functionality
 # if (MX_ADC_VREF_OPT! = 0)
 st_bit (adcon1, VCFG0);
 # endif


Flowcode5 PIC_CAL_ADC.c line in the following file:
// ADC Type 12 Supported Devices
Now...

Code: Select all

 if (Vref! = 0) / / assign VREF Functionality
 st_bit (adcon0, VCFG0);

Change to...

Code: Select all

 Rewriting: if (Vref! = 0) / / assign VREF Functionality
 st_bit (adcon1, VCFG0);

Simulator works, not tested circuit.
Attachments
PIC_CAL_ADC.c
(89.72 KiB) Downloaded 174 times
These users thanked the author STibor for the post:
Enamul (Mon Aug 20, 2012 12:59 pm)
Rating: 5%
 

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: ADC - error during compile.

Postby Enamul » Mon Aug 20, 2012 1:06 pm

Hi,
Yes. You are right as datasheet says the same..This snapshot from ADCON1 register not from ADCON0.
ADC_Vref.png
ADC_Vref.png (8.73 KiB) Viewed 2366 times

Thanks for letting us know.
Enamul
University of Nottingham
enamul4mm@gmail.com