Hi all,
I am trying to read an analogue input on AN3 on a PIC18F45K22 .
Whatever voltage I put on the input, 0 to 5 V, always reads 255.
(Macro "initialise" is part of a larger project but this bit won't work at all without it)
I've tried a new PIC.
Can someone have a look please?
Thanks,
Dave.
(sorry, forgot file!)
Analogue input always reading 255
Moderator: Benj
-
- Flowcode v5 User
- Posts: 104
- Joined: Fri Oct 10, 2014 11:15 am
- Has thanked: 27 times
- Been thanked: 22 times
- 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: Analogue input always reading 255
Hi Dave,
I've just looked at the code for the ADC on the K22 devices and it looks to be ok. The ADC component in your project is pointed to AN0 though I'm guessing this isn't the cause of the issue.
Maybe try a conversion rate other then the FRC setting.
Might also be worth getting rid of the C code ADCON and ANSEL bits, the ADC component should take care of all this for you.
I've just looked at the code for the ADC on the K22 devices and it looks to be ok. The ADC component in your project is pointed to AN0 though I'm guessing this isn't the cause of the issue.
Maybe try a conversion rate other then the FRC setting.
Might also be worth getting rid of the C code ADCON and ANSEL bits, the ADC component should take care of all this for you.
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
-
- Flowcode v5 User
- Posts: 104
- Joined: Fri Oct 10, 2014 11:15 am
- Has thanked: 27 times
- Been thanked: 22 times
Re: Analogue input always reading 255
Hi Benj,
I've spent hours on this, adding bits in like the ADCON and ANSEL bits, trying to get it to work. It was definately pointing to AN3 originally.
I removed the ADCON and ANSEL bits, pointed it back to AN3 and it all works!
I'll add it back to the original program very carefully.
Thanks for your help.
Dave
I've spent hours on this, adding bits in like the ADCON and ANSEL bits, trying to get it to work. It was definately pointing to AN3 originally.
I removed the ADCON and ANSEL bits, pointed it back to AN3 and it all works!
I'll add it back to the original program very carefully.
Thanks for your help.
Dave