RA4/TOCKI in 16F84A

Discussion in 'Embedded Systems and Microcontrollers' started by tracecom, May 20, 2012.

  1. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    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.

    Code ( (Unknown Language)):
    1. ' 2nd PICBasic Pro Program
    2. ' Scans all 13 LEDs connected to 16F84A
    3. OUTPUT PORTA.4
    4. Scan:
    5. Pause 2000  ' Wait 2 seconds.
    6. High PORTA.0 ' Turn on LED connected to RA0.
    7. Pause 250  ' Wait 1/4 second.
    8. Low PORTA.0  ' Turn off LED connected to RA0.
    9. High PORTA.1 ' Turn on LED conndected to RA1.
    10. Pause 250  ' Wait 1/4 second.
    11. Low PORTA.1  ' Turn off LED connected to RA1.
    12. High PORTA.2 ' Turn on LED connected to RA2.
    13. Pause 250  ' Wait 1/4 second.
    14. Low PORTA.2  ' Turn off LED connected to RA2.
    15. High PORTA.3 ' Turn on LED connected to RA3.
    16. Pause 250  ' Wait 1/4 second.
    17. Low PORTA.3  ' Turn off LED connected to RA3.
    18. High PORTA.4 ' Turn on LED connected to RA4.
    19. Pause 250  ' Wait 1/4 second.
    20. Low PORTA.4  ' Turn off LED connected to RA4.
    21. High PORTB.0 ' Turn on LED connected to RB0.
    22. Pause 250  ' Wait 1/4 second.
    23. Low PORTB.0  ' Turn off LED connected to RB0.
    24. High PORTB.1 ' Turn on LED connected to RB1.
    25. Pause 250  ' Wait 1/4 second.
    26. Low PORTB.1  ' Turn off LED connected to RB1.
    27. High PORTB.2 ' Turn on LED connected to RB2.
    28. Pause 250  ' Wait 1/4 second.
    29. Low PORTB.2  ' Turn off LED connected to RB2.
    30. High PORTB.3 ' Turn on LED connected to RB3.
    31. Pause 250  ' Wait 1/4 second.
    32. Low PORTB.3  ' Turn off LED connected to RB3.
    33. High PORTB.4 ' Turn on LED connected to RB4.
    34. Pause 250  ' Wait 1/4 second.
    35. Low PORTB.4  ' Turn off LED connected to RB4.
    36. High PORTB.5 ' Turn on LED connected to RB5.
    37. Pause 250  ' Wait 1/4 second.
    38. Low PORTB.5  ' Turn off LED connected to RB5.
    39. High PORTB.6 ' Turn on LED connected to RB6.
    40. Pause 250  ' Wait 1/4 second.
    41. Low PORTB.6  ' Turn off LED connected to RB6.
    42. High PORTB.7 ' Turn on LED connected to RB7.
    43. Pause 250  ' Wait 1/4 second.
    44. Low PORTB.7  ' Turn off LED connected to RB7.
    45. GoTo Scan  ' Loop back - repeat cycle & scan forever.
    46.  
     
    Last edited: May 20, 2012
  2. Papabravo

    Expert

    Feb 24, 2006
    10,140
    1,789
    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.
     
  3. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
Loading...