PIC18F2523 12 bit adc

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
pheelius
Posts: 7
Joined: Sat Oct 08, 2005 6:31 pm
Location: Guildford, Surrey
Contact:

PIC18F2523 12 bit adc

Post by pheelius »

Is there any way of accessing the full 12 bits of the PIC18F2523's ADC, it seems to be restricted to the usual 10bits of the majority of the PICs.

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:

Post by Benj »

Hello

I will look into this for you.

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:

Post by Benj »

Ok I think I have fixed the problem now

Open the FCD file for the 18F2523. and edit the following line.

Code: Select all

ADCFull="short iRetVal;\niRetVal = (adresh << 2);\niRetVal += (adresl >> 6);\nreturn (iRetVal);\n"
Change it to the following

Code: Select all

ADCFull="short iRetVal;\niRetVal = (adresh << 4);\niRetVal += (adresl >> 4);\nreturn (iRetVal);\n"
Then restart Flowcode and you should now have access to all 12 ADC bits.

Note: This fix will also work for the 18F2423, 18F4423 and 18F4523

pheelius
Posts: 7
Joined: Sat Oct 08, 2005 6:31 pm
Location: Guildford, Surrey
Contact:

Post by pheelius »

i've just tried what you suggested but when I read the adc of a pic18f2523 as an integer and display it in on an lcd I still only get a 10 bit value.

pheelius
Posts: 7
Joined: Sat Oct 08, 2005 6:31 pm
Location: Guildford, Surrey
Contact:

Post by pheelius »

Found what else you need to do, at the beginning of the fcd files you also need to change the line:

ADCBits=10

to

ADCBits=12


javascript:emoticon(':D')
Very Happy :D

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:

Post by Benj »

Hello

Thanks for that. Is it running with the proper 12 bit accuracy now.

Post Reply