christina86
Newbie level 5
Hi everybody,
I'm using the PIC16C745 microchip to do my final year project
I have encounter some problem.the situation is,
if switch 1 is pressed, LED will light up and when switch 2 is pressed again, the LED will go off. I am using an assembly language ( sofware MPLab version 7.2) to write the code.
I have succesffuly bulit the code to the PIC16C745 chip, but the led fail to on.
Here is my code :
MAIN org 00000030h
Start
clrf PORTB ; clear PORTB output latch
movlw b'00000000' ; Set all pins PORTB as output
MOVWF TRISB ;
ON
btfsc PORTA,4 ; Has S2 been press? (Normally high,goes low when pressed.)
goto ON ; No, go back check again
movlw b'00000001' ; move it from register 1 to w.
movwf PORTB ; move it to PORTB to light up the LED
OFF
btfsc PORTA,5 ; Has key been press? (Normally high, goes low when pressed.)
goto OFF ; No, check again
movlw b'00000000' ; move it from register 1 to w.
movwf PORTB ; OFF the LED
DebounceA
btfss PORTA,4 ; Has key been released?
goto DebounceA ; No, wait again
goto Start ; Loop again
end ; directive indicates end of code
Can anyone help me with the code weather i have done it correctly and how the circuit will look like ?
Thank you so much !
I'm using the PIC16C745 microchip to do my final year project
I have encounter some problem.the situation is,
if switch 1 is pressed, LED will light up and when switch 2 is pressed again, the LED will go off. I am using an assembly language ( sofware MPLab version 7.2) to write the code.
I have succesffuly bulit the code to the PIC16C745 chip, but the led fail to on.
Here is my code :
MAIN org 00000030h
Start
clrf PORTB ; clear PORTB output latch
movlw b'00000000' ; Set all pins PORTB as output
MOVWF TRISB ;
ON
btfsc PORTA,4 ; Has S2 been press? (Normally high,goes low when pressed.)
goto ON ; No, go back check again
movlw b'00000001' ; move it from register 1 to w.
movwf PORTB ; move it to PORTB to light up the LED
OFF
btfsc PORTA,5 ; Has key been press? (Normally high, goes low when pressed.)
goto OFF ; No, check again
movlw b'00000000' ; move it from register 1 to w.
movwf PORTB ; OFF the LED
DebounceA
btfss PORTA,4 ; Has key been released?
goto DebounceA ; No, wait again
goto Start ; Loop again
end ; directive indicates end of code
Can anyone help me with the code weather i have done it correctly and how the circuit will look like ?
Thank you so much !