ADCON0 – ADC Channel 15 Error

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
viki2000
Posts: 189
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

ADCON0 – ADC Channel 15 Error

Post by viki2000 »

I have simple code producing PWM output in order to generate a sine wave using lookup table.
The code is below.
PIC18F4550_PWM_SINE.fcfx
FlowCode code
(6.81 KiB) Downloaded 132 times
When I import the hex file in the PROTEUS ISIS, then I got an error related with ADCON0 register because is set for Channel 15, which does not exist:
Image

The analog channels are not used and seems set as default by FlowCode ADCON0=0x3D.
I have seen that looking into the compiled C file, close to the end of the file:
Image

Have a look on the datasheet on page 267:
Image

How can we correct that error?
Ignoring the reference to Proteus and having in mind only the C code output, how can we make ADCON0 to select other channel, as for instance 0, as default, even it is not used any ADC channel in the application?

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

Re: ADCON0 – ADC Channel 15 Error

Post by Benj »

Hello,

As your not using the ADC I think the Proteus warning can simply be ignored. If you were using an ADC then it would automatically assign the correct ADC channel for you before starting the ADC conversion.

The code at the top of main comes from the chip definition file .fcdx in Flowcode v6 and is mainly there to switch off the default analogue functionality before your Flowcode program begins.

I've fixed the attached FCD file so it should assign 0x00 rather than 0x3D.
18F4550.fcdx
(29.13 KiB) Downloaded 140 times

Stinger1
Posts: 1
Joined: Sun Feb 21, 2021 8:31 am
Contact:

Re: ADCON0 – ADC Channel 15 Error

Post by Stinger1 »

Thanks @Benj for the reply, it really fixed the issue.

But I would like to mention that you have to rename the file @Benj attached with the name of the controller/board you have selected in Flowcode. Now go to C: drive and search for the controller/board you have selected in Flowcode with .fcdx (e.g. PIC18F4550.fcdx) you'll find two files of that name in two different folders. Now replace the new file with the old ones. And it works like charm.

Post Reply