Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
;
SWKEYS equ 0x20 ; debounced switch bits, '1' = pressed
SLATCH equ 0x21 ; switch state latch
SWITCH equ 0x22 ; switch flag bits for MAIN
;
; this routine transfers a new debounced switch press to the SWITCH
; variable for MAIN
;
ISR_Switch_Press
movf SWKEYS,W ; debounced switch bits
xorwf SLATCH,W ; each '1' is a change (press or release)
andwf SWKEYS,W ; each '1' is a "new" switch press
xorwf SWITCH,F ; toggle switch flag bits for use by MAIN
movf SWKEYS,W ; update switch state latch
movwf SLATCH ;
;
; this routine transfers a new debounced switch release to the SWITCH
; variable for MAIN
;
ISR_Switch_Release
movf SWKEYS,W ; debounced switch bits
xorwf SLATCH,W ; each '1' is a change (press or release)
andwf SLATCH,W ; each '1' is a "new" switch release
xorwf SWITCH,F ; toggle switch flag bits for use by MAIN
movf SWKEYS,W ; update switch state latch
movwf SLATCH ;
;
; test "UP" switch
;
Test_UP btfss sw_UP ; is SWITCH,0 a '1' (new switch press)?
goto Test_DOWN ; no, branch, else
bcf sw_UP ; clear bit so we don't process again
; perform "UP" code here
;
;
; test SET mode toggle switch flag
;
SET btfss sw_SET ; is SWITCH,1 a '1' (SET mode on)?
goto NextProc ; no, branch, else
;
; perform SET functions in SET_loop
;
SET_loop
;
; has SET mode been turned off
;
btfsc sw_SET ; SET switch still on?
goto SET_loop ; yes, continue SET operations, else
;
; save any changes and exit
;
;
SWKEYS equ 0x20 ; debounced switch bits, '1' = pressed
SLATCH equ 0x21 ; switch state latch
SWITCH equ 0x22 ; switch flag bits for MAIN
BEEP equ 0x23 ; beep timer
;
; process "new" debounced switch "presses"
;
ISR_Switch_Press
movf SWKEYS,W ; debounced switch bits
xorwf SLATCH,W ; each '1' is a change (press or release)
andwf SWKEYS,W ; each '1' is a "new" switch press
;
skpz ; any "new" presses? no, skip, else
bsf BEEP,5 ; send short 32-msec 500-Hz "beep"
;
xorwf SWITCH,F ; toggle switch flag bits for use by MAIN
movf SWKEYS,W ; update switch state latch
movwf SLATCH ;
;
; BEEP routine (500-Hz when using 1 msec interrupts)
;
movf BEEP,W ; beep timer set?
bz ISR_Next ; no, branch, else
movf PORTA,W ;
xorlw 1<<SPKR ; toggle SPKR port bit in W
movwf PORTA ; toggle actual SPKR pin
decf BEEP,F ; decrement beep timer
;
ISR_Next