I have simple code producing PWM output in order to generate a sine wave using lookup table.
The code is below.
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:
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:
Have a look on the datasheet on page 267:
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?
ADCON0 – ADC Channel 15 Error
- 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: ADCON0 – ADC Channel 15 Error
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: ADCON0 – ADC Channel 15 Error
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.
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.