Re: PIC ADC question
Try this
Have a look at section 11.2, page 112 of the 16F877 datasheet.
There is a table for setting up the ADCON1 register for the PortA i/o.
Pay particular attention to bit 7. This bit sets up for right or left justification of the ADIN result.
For most uses, this bit should be set to '1', right justification.
Bits 0-3 of ADCON1 are used to set up port A to user requirements according to the table. i.e. which pins are analog, which are digital, and what the Vref setup is.
I would also suggest you test your AD program in the free VSM supplied with Proton. This will allow you to test your program before committing to pic.
ADCON1 = %1xxxnnnn
where bit 7 is set for right justification
xxx are don't care
nnnn are set according to user requirement from table. I.E these are the ports you want to set read the input, like this ADCON1 = %1000011 PORTA,0&1 are set has input
The best way to remember is 1=input and 0=output