PDA

View Full Version : How to set one pin as ANALOG all others as DIGITAL, and Vref=Vdd ?



sayzer
- 13th April 2006, 16:19
For F877,

On PortA, how do we set AN0 as analog, all others as digital and Vref=Vdd?
I am trying to have one analog channel and remaining pins as all digital on this port.

Thanks for the help in advance.


-------------------

paul borgmeier
- 13th April 2006, 16:54
Set bits 3-0 of ADCON1 to 1110 (as described in the 877 Datasheet DS30292C, page 112) and you will be all set.

Paul Borgmeier
Salt Lake City, Utah
USA

sayzer
- 14th April 2006, 09:42
Thank you Paul.

In this case, the table shows me, as you already pointed, the following explanation for it; just as I need.

ADCON1 REGISTER for bit3-0: 1110

Meaning that:
AN7=Digital
AN6=Digital
AN5=Digital
AN4=Digital
AN3=Digital
AN2=Digital
AN1=Digital
AN0=Analog
Vref+=Vdd
Vref-=Vss


After setting the channels and the Vref with Bit3-0 as above, then I need to set Bit7 as 1=Right justified. Then, Bit6-5-4 are left untouched as they are 0.

Finally, I come up with an ADCON1 register as follows.

ADCON1=%10001110

I also set ADCON0= %11000001 to match ADCON1.

and it works.

Thanks again for the guidance Paul.