PDA

View Full Version : Selection of analog ports



enauman
- 22nd December 2006, 22:55
Looking at the table for the PCFG3:PCFG0 bits in the ADCON1 register in the Microchip mid range refence handbook (PIC16F876), it appears that you can't select one of the higher order channel numbers as analog input without selecting the ones below as analog as well. In other words, can I use port A3 as analog input and ports A2:A0 for digital? I just want to be sure I'm reading the table correctly.

Archangel
- 23rd December 2006, 08:19
But I think so look at the attachment.
JS

paul borgmeier
- 23rd December 2006, 10:30
You are reading the table correctly, but ...

If you do not care what RA0-RA1 are doing when you are doing your ADC on RA3, then yes, you can have your cake and eat it to.

ADCON1 = 7 ' all digital
do stuff here that requires RA0-RA2 to be digital
ADCON1 = 132 ' RA0, RA1, RA3 = analog, RA2 = digital
do your conversion on RA3 (see Datasheet section 11.3 so that you can see what RA0 RA1 are doing)
ADCON1 = 7 ' all digital again
etc.

Why not use the option where RA0 = analog and the rest digital? (i.e., why not swap your RA3 and RA0 pins assignments?

Archangel
- 24th December 2006, 03:56
You are reading the table correctly, but ...


Why not use the option where RA0 = analog and the rest digital? (i.e., why not swap your RA3 and RA0 pins assignments?
Thanks Paul,
boy I was sure hoping someone who knows what they are talking about would ring in on this one ;)
JS