RA4/TOCKI in 16F84A

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
I just wrote the following code. It seems to do what I want except that RA4 never goes high. I am sure it's due to my ignorance, and I have to somehow enable RA4 to be an output, or something equally easy. What have I missed? Thanks.

Rich (BB code):
' 2nd PICBasic Pro Program
' Scans all 13 LEDs connected to 16F84A
OUTPUT PORTA.4
Scan:
Pause 2000  ' Wait 2 seconds.
High PORTA.0 ' Turn on LED connected to RA0.
Pause 250  ' Wait 1/4 second.
Low PORTA.0  ' Turn off LED connected to RA0.
High PORTA.1 ' Turn on LED conndected to RA1.
Pause 250  ' Wait 1/4 second.
Low PORTA.1  ' Turn off LED connected to RA1.
High PORTA.2 ' Turn on LED connected to RA2.
Pause 250  ' Wait 1/4 second.
Low PORTA.2  ' Turn off LED connected to RA2.
High PORTA.3 ' Turn on LED connected to RA3.
Pause 250  ' Wait 1/4 second.
Low PORTA.3  ' Turn off LED connected to RA3.
High PORTA.4 ' Turn on LED connected to RA4.
Pause 250  ' Wait 1/4 second.
Low PORTA.4  ' Turn off LED connected to RA4.
High PORTB.0 ' Turn on LED connected to RB0.
Pause 250  ' Wait 1/4 second.
Low PORTB.0  ' Turn off LED connected to RB0.
High PORTB.1 ' Turn on LED connected to RB1.
Pause 250  ' Wait 1/4 second.
Low PORTB.1  ' Turn off LED connected to RB1.
High PORTB.2 ' Turn on LED connected to RB2.
Pause 250  ' Wait 1/4 second.
Low PORTB.2  ' Turn off LED connected to RB2.
High PORTB.3 ' Turn on LED connected to RB3.
Pause 250  ' Wait 1/4 second.
Low PORTB.3  ' Turn off LED connected to RB3.
High PORTB.4 ' Turn on LED connected to RB4.
Pause 250  ' Wait 1/4 second.
Low PORTB.4  ' Turn off LED connected to RB4.
High PORTB.5 ' Turn on LED connected to RB5.
Pause 250  ' Wait 1/4 second.
Low PORTB.5  ' Turn off LED connected to RB5.
High PORTB.6 ' Turn on LED connected to RB6.
Pause 250  ' Wait 1/4 second.
Low PORTB.6  ' Turn off LED connected to RB6.
High PORTB.7 ' Turn on LED connected to RB7.
Pause 250  ' Wait 1/4 second.
Low PORTB.7  ' Turn off LED connected to RB7.
GoTo Scan  ' Loop back - repeat cycle & scan forever.
 
Last edited:

Papabravo

Joined Feb 24, 2006
22,111
Read the datasheet carefully. RA4/TOCKI is an "open-drain" output. It must be pulled up (high) with an external resistor. The value of the external resistor should be high enough so that in the low state the pin does not exceed the current sinking capability of of the output driver. I think 47K would be about the maximum value.
 
Top