list p=16F84 ; list directive to define processor
#include <P16F84.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _RC_OSC
; '__CONFIG' directive is used to embed configuration data 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
w_temp EQU 0x0C ; variable used for context saving
status_temp EQU 0x0D ; variable used for context saving
CBLOCK 0x0E
mode ; bit 0 set = wait - clear = OK
; bit 1 button state 0 = off - 1 = on
; bit 2 reset mode 1 = yes - 0 = no
valve_on_time
CounterA
CounterB
CounterC
CounterD
CounterE
temp1
ENDC
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
goto interrupt
main
bcf INTCON,GIE
bcf INTCON,T0IE
bsf STATUS,RP0
bcf OPTION_REG,T0CS ; set timer to timer mode
bcf OPTION_REG,PSA ; select prescaler
bsf OPTION_REG,PS0 ; set prescaler to max value
bsf OPTION_REG,PS1
bsf OPTION_REG,PS2
movlw D'255'
movwf CounterB
movlw D'255'
movwf CounterA
movlw 0
movwf mode
call set_interrupt
spin:
clrwdt
; movlw 3
; subwf mode,W
; btfsc STATUS,Z
; goto out
; goto spin
out:
nop
goto out
;**********************************************************************
set_interrupt:
bsf INTCON,GIE
bsf INTCON,T0IE
return
;**********************************************************************
interrupt
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
bcf INTCON,T0IF ; clear interrupt flag for timer
clrwdt
decfsz CounterA,1
goto exit_interrupt
decfsz CounterB,1
goto exit_interrupt
; bsf mode,0
incf mode ; setting breakpoint here
movlw D'255'
movwf CounterB
movlw D'255'
movwf CounterA
exit_interrupt:
bsf INTCON,T0IF
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt