title "ledon - Turn on a LED when a Button is Pressed"
include "D:/p16F877.inc"
__config (_CP_OFF & _PWRTE_ON & _HS_OSC & _WDT_ON & _BODEN_ON & _LVP_OFF & _DEBUG_ON)
errorlevel -302
;;;;;;;;Vectors ;;
org H'000'
goto MainLine
Initial
bcf STATUS,RP0 ;
bcf STATUS, RP1 ; Bank 0 selected
clrf PORTC
clrf PORTA
bsf STATUS,RP0 ; Bank 1 selected
movlw b'11111110' ; Port C pin 0 Output to speaker
movwf TRISC
movlw b'00000011' ; Port A pin 0,1 input to 2 buttons
movwf TRISA
bcf STATUS,RP0 ; Bank 0 selected
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MainLine
call Initial
MainLoop
btfsc PORTB,0 ; check Button 1, if it is not pushed, skip the next step
call BEEP
btfsc PORTB,1 ; check Button 2, if it is not pushed, skip the next step
call NOBEEP
goto MainLoop
BEEP
BCF STATUS, RP0 ; Bank0
BSF PORTC, 0 ; BEEP ON
RETURN
NOBEEP
BCF STATUS, RP0 ; Bank0
BCF PORTC, 0 ; BEEP OFF
RETURN