;**********************************************************************
list p=10F200 ; list directive to define processor
#include <p10F200.inc> ; processor specific variable definitions
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF ; mcle is off because you use GPIO3
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
temp EQU 0x10 ;example variable definition
cnt_65ms equ 0x11
DelA equ 0x12
DelB equ 0x13
;**********************************************************************
ORG 0xFF ; processor reset vector
; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.
ORG 0x000 ; coding begins here
SetUp
movwf OSCCAL ; update register with factory cal value
movlw b'10000111' ;10000111
;-0------, weak pullups ON
;--0-----, set TMR0
;---0----, set TOSE rising edge
;----0---, set PSA presacler as Timer0
;-----111, set presacale to 256
option ;increments at every 256us
movlw b'00001000' ;GPIO Register GPO,GP3
tris GPIO ;GP3 input, all others outputs
clrf GPIO ;make outputs LOW
Start
call Delay1 ;20mS debounce delay
btfsc GPIO,3 ;Is Sw LOW? - pushed
goto Start ;loop
call beep1 ;40mS beep
bsf GPIO,0 ;activate backlight
call Delay2
clrf cnt_65ms
Timer_90
clrf TMR0
; clrf cnt_65ms
w_tmr0
btfss GPIO,3
goto power_dw
movf TMR0,w
xorlw .255
btfss STATUS,Z
goto w_tmr0
incf cnt_65ms,f
movlw .95
xorwf cnt_65ms,w
btfss STATUS,Z
goto Timer_90
movlw .125
subwf cnt_65ms,w
btfss STATUS,C
call beep1
bcf GPIO,0
call beep1
; btfss GPIO,3
goto SetUp
power_dw ;look at sw if pushed more than 2sec turn off backlight
call Delay2 ;delay 1 second
btfsc GPIO,3 ;Is Sw LOW? - pushed
goto $-2
call Delay2 ;delay 1 second
; call Delay2 ;delay 1 second
btfsc GPIO,3 ;Is Sw LOW? - pushed
goto $-5
bcf GPIO,0 ;de-activate Backlight LED
call beep2 ;40mS beeps
call Delay2
call Delay2
nop
goto SetUp
;************************************************* *****************
; subroutines *
;************************************************* *****************
beep2 call beep1 ; 40mS beep
call Delay1 ; 20mS delay
beep1 movlw .40
movwf temp
goto $+1
decfsz DelA,1
goto $-2
movlw b'00000100' ;spkr pin
xorwf GPIO,F ;spkr bit will toggle
decfsz temp,1
goto $-6
retlw 00
Delay1 movlw .20 ; 20mS delay
movwf temp
goto $+1
decfsz DelA,1
goto $-2
decfsz temp,1
goto $-4
retlw 00
Delay2 movlw .50 ;1 Second delay
movwf DelB
call Delay1
decfsz DelB,1
goto $-2
retlw 00
END ; end of program