PDA

View Full Version : Pulling port high



the_antique
- 11th November 2005, 05:58
At this point I feel like a total idiot. I was debugging a very simple program for a 16F870. It appears that the reason the program would not work properly was that PORTC.4 was not going high when instructed. Removing all unessential parts of the code, I wrote High PORTC.4. When I checked for a high state on the appropriate pin, I found it to be low. I changed chips with the same result. I added High PORTC.5 and, of course, that pin went high while PORTC.4 remained low. Is there something special about PORTC.4 on this chip that I missed?

My code follows:

ADCON1 = 7
TRISA.0 = 1
TRISB = 0
TRISC = 0
HH VAR BYTE
MM VAR BYTE
SS VAR BYTE
DD VAR BYTE
N VAR BYTE
D VAR BYTE
H VAR BYTE
I VAR BYTE
T VAR BYTE
Z VAR BYTE

High PORTC.4
High PORTC.5

Any help will be greatly appreciated.

mister_e
- 11th November 2005, 16:01
As i remind thos baby PIC don't have any multiplexed stuff on PORTC so i'll bet on a messy contact or bad breadboard.

i just hope your code is longer than this.. let's say


ADCON1 = 7
TRISA.0 = 1
TRISB = 0
TRISC = 0
HH VAR BYTE
MM VAR BYTE
SS VAR BYTE
DD VAR BYTE
N VAR BYTE
D VAR BYTE
H VAR BYTE
I VAR BYTE
T VAR BYTE
Z VAR BYTE

High PORTC.4
High PORTC.5
Here:
Goto Here

the_antique
- 11th November 2005, 18:48
Yes, the whole code is a LOT longer. I just truncated it to the bare minimums (except the variable assignments). I still have no idea why that particular port doesn't behave as the others do.

the_antique
- 14th November 2005, 16:57
Yep, I am truly an idiot. I was so concerned that, because I hadn't used the '870 before, I had missed some special feature. Instead the problem was in the circuit wiring with a pull-down attached to the pin.

J. Mark Wolf
- 14th November 2005, 18:18
Some port pins on PIC's are an open-drain output, and need a pull-up resistor to "make" a high signal. RA4 on smaller PIC's in particular.

This one has tripped me up before also.

I havent used the '870, but you can check the "I/O pin diagrams" in the data sheet to determine which pins are "push/pull" (don't need a pull-up) and which are open-drain (need a pull-up).