Simple PIC program not working

Discussion in 'The Projects Forum' started by tigerapna, Mar 23, 2012.

  1. tigerapna

    Thread Starter Member

    Dec 14, 2011
    73
    1
    I am just trying to turn on the LED when the button is pressed but the LED already remains on without a press button.

    What am I doing wrong?

    Code ( (Unknown Language)):
    1. Start:
    2.      bsf     STATUS,RP0       ; select Register Page 1
    3.      bcf     TRISC,0             ; make IO Pin C0 an output
    4.      bsf     TRISA,RA3          ;make IO pin RA3 an input
    5.      bcf     STATUS,RP0       ; back to Register Page 0
    6.      bcf     PORTC,0
    7. loop:    
    8.      btfss   PORTA,RA3
    9.      bsf     PORTC,0          ; turn on LED C0 (DS1)
    10.      goto    loop                
    11.      end
     
    Last edited: Mar 23, 2012
  2. c0de3

    Active Member

    May 1, 2009
    50
    1

    Check the datasheet, what else does RA3 do? Is it perhaps a reset pin or anything like that?
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Most PICs have some kind of analog input functions. And thye are turned on as default after power on on reset. A pin with an analog function will always read '0' What PIC are you using?
     
  4. tigerapna

    Thread Starter Member

    Dec 14, 2011
    73
    1
    I'm using 16F690.

    I am powering it from the PICKIT 2, could this overide signals?
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    In the 16f690 demokit the button is conected to RA3 pin which also is MCLR pin. And PICKIT 2 take control over this pin. You can control the MCLR pin from MPLAB. If you are using the Low pin count demo card. It comes with 12 lessons. Have you looked at them? Also then posting code please post the full code included the __config() setting. As this is important
     
  6. tigerapna

    Thread Starter Member

    Dec 14, 2011
    73
    1
    Yes, I looked through most of them but couldn't figure out why I couldn't use RA5 and RA2 as inputs. I looked up on google and people said PICKIT 2 takes over the signals when not powering from external VDD.

    I am using RB7 and RB6 as inputs and its working fine.

    I can move on with my code :D.

    Thank you for the help with all my posts.
     
Loading...