How to use pin RA4 as digital I/O port? plz help

Status
Not open for further replies.

goug

New Member
I am using PIC 16F877A for a big project, I already used all available ports, but having some problems with PORTA.

I want to use PORTA as a digital I/O port. I just found in 16F877A datasheet how to configure pins 0,1,2,3 and 5 as digital I/O (ADCON1 = %00000111); but can't find how to configure pin 4.

I just can't set or clear pin 4 of PORTA

could anyone help please?
 
RA4 is an open-collector output, you need an external pull-up resistor for it to go high!.
 
>> Using RA4 as an output (TRISA = 0) <<

I tried with the pull-up resistor on pin RA4 (1k + 5V):

Result: RA4 remains high whether it's set or cleared by the PIC!
I don't want that

What could be the problem? (maybe RA4 can not be configured as output? set and cleared when needed)
 
Last edited:
RA4 should work fine as an open collector output with a pull-up resistor to +5v.

One thing that could cause you a problem is that RA4 is also used as an output for the comparator module.
The comparator module is turned off by default at power-on, so should not cause any problem unless you have enabled it.
See section 12 of the data sheet.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…