PDA

View Full Version : PIC16F877 PORTA Input Issue



CocaColaKid
- 6th December 2005, 16:50
I'm trying to configure porta.3 and porta.4 for input on a 877 chip and can not for the life of me get it to work properly. I have the I/O pulled to +5V and it still keeps registering that both ports are 0 for there state. Is there something I missed in the configuration?



ADCON1 = %00001111
ADCON0 = 0
CCP1CON = 0 ' Turn off Capture/Compare/PWM module 1
TRISA = %00011011 ' All outputs except for A0,A1,A3,A4

Darrel Taylor
- 6th December 2005, 18:25
CCK,

Are you sure it's not a 16F877A

If it is, you'll also need   CMCON = 7
<br>

CocaColaKid
- 6th December 2005, 19:04
It is actually the 877 and not the 877A. I thought the same thing at first until I double checked the actual chip. I did however since discover the issue. It has some to do with Bit7 for the ADCON1 register. I made it 1 instead of 0 and everything seems to work fine now. I don't understand why because the A/D is turned off for the justification I would not think would have any bearing on this matter but it seems to.

Darrel Taylor
- 6th December 2005, 19:25
You've GOT to be kidding!

That's the strangest thing I've ever heard about PIC's.

I use ADCON1=7 alot, and have never had to ADCON1=$87 for digital inputs. And, ADCON1=6 works well too.

Is it repeatable? Changing ADCON1.7 back to 0, causes the same thing again?
<br>

CocaColaKid
- 6th December 2005, 19:54
Well this makes no sense but I just checked it again with a 0 and it now works. I'm not sure what to make of this. Maybe I changed something else and forgot that I did that. Not sure what to make of it. It seems to work fine now :(

Bruce
- 6th December 2005, 20:18
ADCON1 = %00001111 is setting RA0 as A/D in, RA2 as -Vref & RA3 as +Vref.

CocaColaKid
- 6th December 2005, 20:27
What does it mean when the datasheet says "Bit is unknown"? How do you make all the ports digital because the datasheet says 011x with x being an unknown?

Bruce
- 6th December 2005, 20:33
X in this case means it doesn't matter what the bit is. ADCON1 = %00000111 or ADCON1 = %00000110 will have the same effect.