karan123
Member level 3
Hello,
I am struggling to Toggle LED with Switch with PIC18F4520.I have written below code. but LED is not toggling properly.
; SW Connected with 4.7 K Pull up Resistance
ORG 0
MOVLF 0xFF
MOVWF ADCON1 ; CONFIGURE all pins Digital
BSF TRISB,1 ; Configure as Input PIN
BCF TRISB,4 ; Configure as Output PIN
AGAIN
BTFSS PORTB,1 ; BIT TEST RB7 for HIGH
GOTO OVER ; ONLY if LOW
BTG LATB,4 ; LED=0 ON
BRA AGAIN
OVER
BRA AGAIN
END
It some time toggle and sometime not, some time light glow.
What the reason?
Thanks
--
Karan
I am struggling to Toggle LED with Switch with PIC18F4520.I have written below code. but LED is not toggling properly.
; SW Connected with 4.7 K Pull up Resistance
ORG 0
MOVLF 0xFF
MOVWF ADCON1 ; CONFIGURE all pins Digital
BSF TRISB,1 ; Configure as Input PIN
BCF TRISB,4 ; Configure as Output PIN
AGAIN
BTFSS PORTB,1 ; BIT TEST RB7 for HIGH
GOTO OVER ; ONLY if LOW
BTG LATB,4 ; LED=0 ON
BRA AGAIN
OVER
BRA AGAIN
END
It some time toggle and sometime not, some time light glow.
What the reason?
Thanks
--
Karan