| 
 
 
 
 
 
 
 
 
 
 
 
 
 tableS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 isr
 
 
 
 
 
 
 
 
 
 
 
 
 isr_0
 
 
 
 
 
 isr_1
 
 
 
 
 
 isr_2
 
 
 
 
 
 
 isr_3
 
 
 
 
 
 
 
 
 isr_4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 isr_5
 
 
 
 
 
 
 isr_6
 
 
 
 
 
 
 
 
 
 
 
 
 
 isr_7
 
 
 
 
 
 
 
 
 
 isr_8
 
 
 
 
 
 
 
 
 
 
 
 
 isr_8a
 
 
 
 
 
 
 isr_9
 
 
 
 
 
 
 
 
 
 
 
 isr_9a
 
 
 
 
 
 
 
 
 isr_9b
 
 
 
 
 
 
 isr_9z
 
 
 
 
 
 
 
 
 
 
 isr_10
 
 
 
 
 
 
 
 isr_11
 
 
 isr_12
 
 
 
 
 
 
 
 
 isr_13
 
 
 
 
 
 
 
 Beep
 
 
 Beep1
 
 
 
 
 
 
 
 Main
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Loop
 
 
 
 
 
 
 
 
 
 
 Check
 
 Check1
 
 
 
 
 
 
 
 Input
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Input1
 
 
 
 Input2
 
 
 Input3
 
 Input4
 
 
 
 
 
 M_look
 
 
 
 
 
 
 
 
 
 
 
 
 
 M_Look1
 
 M_trig
 
 
 
 
 
 
 
 
 
 
 
 
 Enable
 
 
 
 
 
 
 
 
 
 Exit
 
 
 
 
 
 
 
 
 
 
 Exit1
 
 Exit2
 
 
 
 
 
 
 
 
 
 
 Del1
 
 Del1A
 
 
 
 
 
 
 Del1B
 
 
 
 
 
 
 Del2
 
 Del2A
 
 
 
 
 
 
 Del2B
 
 
 
 
 
 
 
 Alrm_go
 
 
 
 
 
 
 
 
 
 Alrm_r
 
 
 Alrm_z
 
 
 
 
 
 Entry
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Entry1
 
 Entry2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 SetYel
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 SetRed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 SetDis
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Deboun
 | ORG 0 GOTO Main
 NOP
 NOP
 ORG 4
 GOTO isr
 
 
 
 
 
 
 
 
 addwf PCL,1
 retlw 0x0A0
 retlw 0x025
 retlw 0x0A0
 retlw 0x035
 retlw 0x0A0
 retlw 0x070
 retlw 0x020
 retlw 0x050
 retlw 0x0A0
 retlw 0x030
 retlw 0x0A0
 retlw 0x050
 retlw 0x090
 retlw 0x050
 retlw 0x0A0
 retlw 0x070
 retlw 0x0A0
 retlw 0x050
 retlw 0x020
 retlw 0x050
 retlw 0x020
 retlw 0x050
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 MOVWF W_sav
 SWAPF STATUS,W
 BCF STATUS,RP0
 MOVWF Stat_sav
 BTFSS Alarm_state, flg_Dis
 GOTO isr_0
 DECFSZ tmr_Rearm3,1
 GOTO isr_0
 DECFSZ tmr_Rearm2,1
 GOTO isr_0
 DECFSZ tmr_Rearm1,1
 GOTO isr_0
 CALL Enable
 BTFSS mi_Flgs, flg_Deboun
 GOTO isr_1
 DECFSZ tmr_Deboun,1
 GOTO isr_2
 BCF mi_Flgs, flg_Deboun
 
 BTFSS tmr_Flg1, flg_Clk
 GOTO isr_2
 DECFSZ tmr_Clk,1
 GOTO isr_2
 BCF tmr_Flg1, flg_Clk
 
 BTFSS tmr_Flg1, flg_Verb
 GOTO isr_3
 DECFSZ tmr_Verb1,1
 GOTO isr_3
 BCF tmr_Flg1, flg_Verb
 BCF PORTB, bit_Verb
 
 BTFSS tmr_Flg1, flg_Strobe
 GOTO isr_4
 DECFSZ tmr_Strobe1,1
 GOTO isr_4
 DECFSZ tmr_Strobe2,1
 GOTO isr_4
 BCF tmr_Flg1, flg_Strobe
 BCF PORTB, bit_Strobe
 
 BTFSS tmr_Flg1, flg_Buzz
 GOTO isr_5
 DECFSZ tmr_Buzz1,1
 GOTO isr_5
 MOVLW 0x10
 XORWF PORTB,1
 MOVLW 0x0FF
 BTFSS PORTB, bit_Buzz
 MOVLW 0x080
 MOVWF tmr_Buzz1
 DECFSZ tmr_Buzz2,1
 GOTO isr_5
 BCF tmr_Flg1, flg_Buzz
 BCF PORTB, bit_Buzz
 
 BTFSS tmr_Flg1, flg_Dog
 GOTO isr_6
 DECFSZ tmr_Dog1,1
 GOTO isr_6
 BCF tmr_Flg1, flg_Dog
 BCF PORTB, bit_Dog
 
 BTFSS tmr_Flg1, flg_Siren
 GOTO isr_7
 DECFSZ tmr_Siren, 1
 GOTO isr_7
 MOVLW 0x20
 XORWF PORTB,1
 MOVF tbl_i,0
 CALL tableS
 MOVWF tmr_Siren
 DECFSZ tbl_i,1
 GOTO isr_7
 BCF tmr_Flg1, flg_Siren
 BCF PORTB, bit_Siren
 
 BTFSS tmr_Flg1, flg_Disarm
 GOTO isr_8
 DECFSZ tmr_Disarm1,1
 GOTO isr_8
 BCF tmr_Flg1, flg_Disarm
 CALL SetDis
 MOVLW 0xFF
 MOVWF tmr_Deboun
 BSF mi_Flgs, flg_Deboun
 
 BTFSS tmr_Flg2, flg_Waita
 GOTO isr_9
 DECFSZ tmr_Delay1,1
 GOTO isr_9
 DECFSZ tmr_Delay2,1
 GOTO isr_9
 BCF tmr_Flg2, flg_Waita
 CALL Beep
 BTFSS Alarm_state, flg_Yellow
 GOTO isr_8a
 CALL SetYel
 GOTO isr_9
 
 BTFSC Alarm_state, flg_Red
 CALL SetRed
 
 
 
 
 
 BTFSS Alarm_state, flg_Ena
 GOTO isr_10
 DECFSZ tmr_Blink,1
 GOTO isr_10
 BTFSS tmr_Flg2, flg_Waitb
 GOTO isr_9a
 MOVLW b'00000100'
 BTFSC PORTB, bit_Gre
 MOVLW b'00000000'
 IORWF PORTB, 1
 GOTO isr_9z
 
 BTFSS mi_Flgs,flg_Zone2
 GOTO isr_9b
 MOVLW b'00000100'
 BTFSC PORTB, bit_Gre
 MOVLW b'00000010'
 BTFSC PORTB, bit_Yel
 MOVLW b'00000001'
 GOTO isr_9z
 
 MOVLW b'00000100'
 BTFSC PORTB, bit_Gre
 MOVLW b'00000001'
 BTFSC PORTB, bit_Red
 
 
 
 MOVLW b'00000010'
 BCF PORTB, bit_Gre
 BCF PORTB, bit_Yel
 BCF PORTB, bit_Red
 IORWF PORTB, 1
 MOVLW lmt_Blink
 MOVWF tmr_Blink
 
 
 
 
 BTFSS tmr_Flg2, flg_Waitb
 GOTO isr_11
 DECFSZ tmr_Delay1, 1
 GOTO isr_11
 DECFSZ tmr_Delay2, 1
 GOTO isr_11
 BCF tmr_Flg2, flg_Waitb
 
 NOP
 
 
 BTFSS tmr_Flg2, flg_Amp_On
 GOTO isr_13
 DECFSZ tmr_Amp_On1,1
 GOTO isr_13
 DECFSZ tmr_Amp_On2,1
 GOTO isr_13
 BCF tmr_Flg2, flg_Amp_On
 BSF PORTA, bit_Amp_On
 
 BCF INTCON,T0IF
 BCF INTCON,INTF
 SWAPF Stat_sav,W
 MOVWF STATUS
 SWAPF W_sav,F
 SWAPF W_sav,W
 RETFIE
 
 BSF PORTB,4
 MOVLW 0x80
 MOVWF ExitDel2
 DECFSZ ExitDel1
 GOTO Beep1
 DECFSZ ExitDel2
 GOTO Beep1
 BCF PORTB,4
 RETURN
 
 
 CLRF PORTA
 MOVLW 0x07
 MOVWF CMCON
 CLRF PORTB
 BCF STATUS, RP1
 BSF STATUS, RP0
 MOVLW b'00000111'
 MOVWF TRISA ^ 0x080
 CLRF TRISB ^ 0x080
 CLRWDT
 MOVLW b'00000100'
 
 
 
 
 MOVWF Option_Reg ^ 0x080
 BCF STATUS, RP0
 CLRF TMR0
 CALL SetDis
 MOVLW 0xA0
 MOVWF INTCON
 CLRF mi_Flgs
 BSF mi_Flgs,flg_RAoff
 
 
 
 BTFSC mi_Flgs, flg_Deboun
 GOTO M_look
 BTFSS tmr_Flg1, flg_Disarm
 GOTO Check
 BTFSS PORTA,0
 GOTO Check1
 Call Deboun
 GOTO M_look
 
 
 
 BTFSC PORTA,0
 GOTO Input
 BTFSC mi_Flgs,flg_RAoff
 GOTO M_look
 CALL Deboun
 BSF mi_Flgs,flg_RAoff
 BCF tmr_Flg1, flg_Disarm
 GOTO M_look
 
 
 BTFSS mi_Flgs,flg_RAoff
 GOTO Input3
 CALL Deboun
 BCF mi_Flgs,flg_RAoff
 BTFSS Alarm_state,flg_Ena
 GOTO Input1
 INCF cnt_Clicks,1
 MOVLW 0x03
 SUBWF cnt_Clicks,0
 BTFSS STATUS,Z
 GOTO Input4
 MOVLW b'00000010'
 XORWF mi_Flgs,flg_Zone2
 CLRF cnt_Clicks
 GOTO Input4
 BTFSS tmr_Flg1, flg_Clk
 GOTO Input2
 CALL Enable
 GOTO M_look
 MOVLW lmt_Clk
 MOVWF tmr_Clk
 BSF tmr_Flg1, flg_Clk
 BTFSC Alarm_state, flg_Dis
 GOTO Loop
 MOVLW lmt_Disarm
 MOVWF tmr_Disarm1
 BSF tmr_Flg1, flg_Disarm
 
 
 
 BTFSC Alarm_state, flg_Dis
 GOTO Loop
 BTFSC tmr_Flg2, flg_Waita
 GOTO Loop
 BTFSC tmr_Flg2, flg_Waitb
 GOTO Loop
 BTFSC tmr_Flg2, flg_Trig
 GOTO Loop
 BTFSC tmr_Flg1, flg_Strobe
 GOTO Loop
 BTFSC mi_Flgs,flg_Zone2
 GOTO M_Look1
 BTFSC PORTA,bit_Z2
 GOTO M_trig
 BTFSC PORTA,bit_Z1
 GOTO Loop
 CALL Alrm_go
 GOTO Loop
 
 
 
 
 
 
 
 
 
 
 
 CLRF 4Eh
 CLRF cnt_Clicks
 CLRF tmr_Flg1
 CLRF tmr_Flg2
 CLRF PORTB
 BSF PORTA, bit_Amp_On
 MOVLW 0x00
 MOVWF INTCON
 MOVLW 30h
 MOVWF 4Dh
 BSF 06,2
 BSF 06,4
 CALL Del2
 BCF 06,4
 CALL Del1
 BCF 06,2
 CALL Del1
 BTFSS 4Eh,0
 GOTO Exit1
 BCF 4Eh,0
 GOTO Exit2
 DECFSZ 4Dh,1
 GOTO Exit
 MOVLW 0x0A0
 MOVWF INTCON
 CLRF tmr_Delay1
 MOVLW 0x03
 MOVWF tmr_Delay2
 CLRF Alarm_state ;
 BSF Alarm_state, flg_Ena
 BCF tmr_Flg2,flg_Waita
 BSF tmr_Flg2,flg_Waitb
 RETURN
 
 MOVLW 0A0h
 MOVWF 4Bh
 NOP
 MOVLW 2Ch
 SUBWF 4Dh,0
 BTFSC 03,0
 GOTO Del1B
 BTFSC 05,0
 BSF 4E,0
 DECFSZ 4C,1
 GOTO Del1A
 DECFSZ 4B,1
 GOTO Del1A
 RETURN
 
 
 MOVLW 20h
 MOVWF 4Bh
 NOP
 MOVLW 2Ch
 SUBWF 4Dh,0
 BTFSC 03,0
 GOTO Del2B
 BTFSC 05,0
 BSF 4E,0
 DECFSZ 4C,1
 GOTO Del2A
 DECFSZ 4B,1
 GOTO Del2A
 RETURN
 
 
 
 CALL Beep
 BCF PORTB, bit_Gre
 BCF PORTB, bit_Red
 BCF PORTB, bit_Yel
 BTFSS Alarm_state, flg_Ena
 GOTO Alrm_r
 CLRF Alarm_state
 BSF Alarm_state, flg_Yellow
 BSF PORTB, bit_Yel
 GOTO Alrm_z
 CLRF Alarm_state
 BSF Alarm_state, flg_Red
 BSF PORTB, bit_Red
 CLRF 4Eh
 MOVLW 0x00
 MOVWF INTCON
 MOVLW 30h
 MOVWF 4Dh
 BCF 06,1
 BSF 06,0
 BSF 06,4
 CALL Del2
 BCF 06,4
 CALL Del2
 BSF 06,4
 CALL Del2
 BCF 06,4
 CALL Del1
 BCF 06,0
 CALL Del1
 BTFSS 4Eh,0
 GOTO Entry1
 BCF 4Eh,0
 GOTO Entry2
 DECFSZ 4Dh,1
 GOTO Entry
 MOVLW 0x0A0
 MOVWF INTCON
 MOVLW 0x0FF
 MOVWF tmr_Delay1
 MOVLW 0x02
 MOVWF tmr_Delay2
 BCF tmr_Flg2, flg_Waitb
 BSF tmr_Flg2, flg_Waita
 BCF PORTA, bit_Amp_On
 CLRF tmr_Amp_On1
 MOVLW lmt_Amp_On2
 MOVWF tmr_Amp_On2
 BSF tmr_Flg2, flg_Amp_On
 RETURN
 
 
 
 CLRF tmr_Strobe1
 MOVLW lmt_Strobe2
 MOVWF tmr_Strobe2
 BSF tmr_Flg1, flg_Strobe
 BSF PORTB, bit_Strobe
 MOVLW 0x01
 MOVWF tmr_Siren
 MOVLW 0x015
 MOVWF tbl_i
 BSF tmr_Flg1, flg_Siren
 MOVLW 0x040
 MOVWF tmr_Verb1
 BSF tmr_Flg1, flg_Verb
 BSF PORTB, bit_Verb
 MOVLW 0x040
 MOVWF tmr_Dog1
 BSF tmr_Flg1, flg_Dog
 BSF PORTB, bit_Dog
 RETURN
 
 
 CLRF tmr_Strobe1
 MOVLW lmt_Strobe2
 MOVWF tmr_Strobe2
 BSF tmr_Flg1, flg_Strobe
 BSF PORTB, bit_Strobe
 MOVLW 6
 MOVWF tmr_Buzz1
 MOVLW 19
 MOVWF tmr_Buzz2
 BSF tmr_Flg1, flg_Buzz
 BCF PORTB, bit_Buzz
 MOVLW 0x040
 MOVWF tmr_Dog1
 BSF tmr_Flg1, flg_Dog
 BSF PORTB, bit_Dog
 RETURN
 
 
 
 
 MOVLW 1
 MOVWF Alarm_state
 CLRF tmr_Flg1
 CLRF tmr_Flg2
 CLRF cnt_Clicks
 MOVLW b'00000100'
 MOVWF PORTB
 BSF PORTA, bit_Amp_On
 MOVLW 0x0FF
 MOVWF tmr_Rearm1
 MOVWF tmr_Rearm2
 MOVLW 0x01A
 MOVWF tmr_Rearm3
 RETURN
 
 
 
 MOVLW lmt_Deboun
 MOVWF tmr_Deboun
 BSF mi_Flgs, flg_Deboun
 RETURN
 
 END
 | 
 
 
 
 ;interrupts always vector (come) to here
 
 Table for siren intervals (makes siren wail at ;uneven
             intervals. If you move the call to this
 ;table 
             from the isr
             routine to another memory ;location or move this table,
             check Microchip
 ;pub ANS556 
             to avoid some possible
             problems.
 
 
 
 ;1
 ;2
 ;3
 ;4
 ;5
 ;6
 ;7
 ;8
 ;9
 ;A
 ;B
 ;C
 ;D
 ;E
 ;F
 ;10
 ;11
 ;12
 ;13
 ;14
 ;15
 ;16
 
 ;Interrupt Service Routine (ISR). 
             Servicing TMR0 interrupts only. This ISR allows Main to turn on 
             an output port, set up a counter that specifies how many timer 
             interrupts (2048 microseconds intervals) a function is to remain on. 126 (0x07E) 
             intervals is about 1 second. It is also used for other functions 
             that need something done after a certain time interval such as setting a 'debounce-off' flag, implement a delay before enabling the 
             alarm (to allow someone to leave),
 implement a delay before going to a Yellow or Red Alert mode, 
             maintaining a time-out interval for "double clicks" on RA0 input 
             and others
 
 
 
 
 ;first save critical 
             registers
 ;always change to bank 0
 
 ;is alarm 
             disabled?
 ;no
 
 
 
 ;This code eventually enables the 
             alarm
 in a few hours. I put 
             this in because I would get distracted and forget to enable the alarm after I left the garage.
 
 ;Debouncing?
 ;no
 ;time up?
 ;no
 ;Turn off "debounce 
             in progress" flag
 
 ;looking for a 
             double click?
 
 ;count down
 
 ;yes - time is up
 
 ;verbal 
             warning timer on?
 ;no
 
 
 
 ;turn off verbal warning
 
 ;strobe 
             light timer on?
 ;no
 
 
 ;count-down reached?
 
 
 ;turn off strobe
 
 ;Buzzer/Horn 
             handling ?
 ;no
 
 
 ;buzzer/horn bit
 ;reverse PORTB Buzzer State
 ;set buzzer-on interval
 ;is buzzer on?
 ;yes, set buzzer-off interval
 
 ;count-down times buzzer 
             is turned on and off
 ;limit not reached
 
 ;turn off buzzer
 
 ;Barking dogs 
             handling? (amplifier should be on)
 
 
 
 
 ;turn off barking dogs
 
 ;Siren 
             handling?
 ;no
 
 
 ;Siren bit
 ;Reverse PORTB Siren State
 
 ;Call Siren table
 ;set siren interval timer
 
 
 
 ;turn off siren
 
 ;Disarm?
 
 ;has switch been closed 
             long enough?
 
 ;yes - we have a 
             Disarm command
 
 ;give user 2.1 seconds to release switch after
 ;Disarm is 
             triggered before more RA0 
             inputs are ;processed
 
 ;Waiting to 
             set off alarm
 ;no
 ;wait several seconds in 
             case someone
 ;entered to turn off alarm.
 ;count-down reached?
 ;no
 
 
 
 
 ;yellow alert
 
 
 
 ; red alert
 
 
 
 ;If the alarm is in "enabled" mode, then blink
 ;lights from from top to bottom (or bottom to top
 ;if 
             Zone 2 is disabled)
 ;is alarm in 
             enabled mode?
 ;no
 ;time to blink a 
             different color?
 ;no
 ;Are we waiting to 
             enable alarm?
 ;no
 ;set green as default 
             color
 ;was PortB green led 
             already on?
 ;no then set W = no LEDs
 ;update PORTB with new LED 
             display
 
 
 ;Zone 2 
             disabled?
 ;no reverse order lights blink
 ;set green as default 
             color
 ;was PortB green led 
             already on?
 ;then set W = yellow LED
 ;was PortB yellow LED already on?
 ;then set W = Red
 
 ;Blink lights in 
             reverse order of isr_9
 ;was PortB green LED 
             already on?
 ;then set W = Red
 ;was PortB yellow led 
             already on?
 
 
 
 ;then set W = yellow led
 
 
 
 ;update PORTB with new LED 
             display
 
 ;Reset count-down timer
 
 ;Allow time for someone to leave 
             before clearing ;flg_Waitb.  All motion detector input is ignored
 ;until flg_Waitb is clear.
 ;Flag set?
 ;no
 ;wait for another interrupt?
 ;yes
 ;yet some more?
 ;yes
 ;clear flag
 
 ;not used
 
 ;power off the amplifier after the 
             specified time.
 ;is amplifier on?
 ;no
 
 
 
 
 
 ;turn off amplifier
 
 
 
 
 ;restore status (and Bank used at time of
 ;interrupt)
 ;restore w without changing 
             status
 
 
 
 
 
 
 
 
 
 
 
 ;Main program - Setup
 
 ;clear Port A
 ;turn comparators off and enable
 ;pins for I/O functions
 ;clear Port B
 
 ;select bank 1
 ;RA0, RA1, RA2 = input
 
 ;Port B - all output
 ;clear WDT and prescaler
 ;prescaler (1:32)
 
 
 ;use MOVLW b'00000001' prescaler - for debugging
 
 ;TMR0 interrupts = 6 microseconds apart
 ;bank 0
 ;clear Timer0 register
 ;startup in disabled mode
 ;set GIE <7> and T0IE <5>
 ;enable Interrupts
 ;miscellaneous flags
 ;Set button released 
             flag
 
 Main program - Loop
 
 ;debounce in 
             progress?
 ;yes - skip RA0 input processing
 ;disarm in 
             progress?
 ;no - do normal RA0 input processing
 ;still in progress?
 ;no - do normal RA0 input processing
 ;Yes - debounce here to 
             implement a 'sampling' ;effect. Skip RA0 input processing
 
 ; Main Loop - Check for command input (commands entered via the 
             momentary switch)
 ;check RA0 (command input)
 ;RA0 is high so go process it
 ;RA0 is low - 
             just released?
 ;No - it has been low
 ;Debounce
 ;Set "RA0 is low" flag
 ;turn any off 
             disarm-in-progress
 
 
 ;Main Loop - Process command input.
 ;just turned on?
 ;no - this can happen only on 2nd click of a
 ;double-click.  Yes - so debounce it
 ;Set "RA0 is high" 
             flag
 ;is alarm enabled?
 ;No
 
 ;number Clicks = 3
 ;while in enabled mode?
 
 
 
 ;reverse Zone2 enabled/disabled status
 
 
 ;were we 
             waiting for a double click?
 ;no
 
 
 ;get double-click 
             interval
 
 ;start the double 
             click timer
 ;is alarm 
             already disabled?
 ;yes
 ;start 
             'disarm-in-progress'
 
 ;start the disable 
             command timer
 
 ;Main Loop - looks for input from the 
             motion detectors.
 ;is alarm 
             disabled?
 ;yes - don't look for an intruder
 ;give someone time to enter & turn off alarm
 
 ;give someone 
             time to enable & leave room?
 ;yes
 ;already processing 
             a motion trigger?
 ;yes
 ;is strobe light 
             on ?
 ;yes, let existing alarm complete
 ;is zone-2 disabled?
 ;yes - check zone-1
 ;zone-2 low? (normally low)
 ;No
 ;zone-1 high? (normally high)
 ;Yes
 
 
 
 ;Subroutines - Logic in the Main Loop was
 ;simplified by moving code that performed a
 ;well-defined function to a subroutine.
 Sometimes that is the sole purpose of a
 ;subroutine, and, in fact does 
             not shorten the
 ;program or improve anything but readability.
 
 
 Subroutine - Enable/Reset the 
             alarm
 
 
 ;clear button-detect flag in delay routine
 
 
 
 ;clear Port B - stop all alarms
 ;turn off amplifier
 
 ;turn off interrupts
 ;number of beeps/flashes
 ;storage file for decrementing
 ;turn on green LED
 ;turn on beeper
 ;short delay
 ;turn off beeper
 ;call long delay
 
 
 
 
 ;reset the "button-pressed" flag
 
 
 
 
 ;turn on interrupts
 ; set delay
 ; wait another 2 seconds to enable
 
 
 ; Set alarm to enabled mode
 
 
 
 
 ;this is the long delay
 ;file to decrement
 
 ;allow 3 beeps before button detected
 
 ;test carry flag. Will be SET if more than file 2Dh
 
 
 ;button has been detected- flag it
 
 
 
 
 
 
 
 ;this is the short delay
 ;file to decrement
 
 ;allow 3 beeps before button detected
 
 ;test carry flag. Will be set if more
 
 
 ;button has been detected- flag it
 
 
 
 
 
 
 Subroutine - Turn on Alarm
 Set delay 
             time and flags for isr routine.
 
 
 
 
 ;previously 
             triggered?
 ;yes
 
 
 ;set LEDs to yellow alert
 
 
 
 ;set LEDs to Red alert
 ;clear "button-pressed" flag file
 
 ;turn off interrupts
 ;48 beeps/flashes for entry
 
 ;clear orange LED
 ;turn on red LED
 ;turn on beeper
 ;short delay
 ;turn off beeper
 ;short delay
 ;turn on beeper
 ;short delay
 ;turn off beeper
 ;call long delay
 
 
 ;test button-detect flag
 
 ;clear button-detect flag in delay routine
 
 
 
 
 ;turn on interrupts
 ;Set delay time for two extra seconds
 
 
 
 ;clear exit delay flag
 ;set entry delay flag
 ;turn on amp (Yes - LOW to turn amp on)
 ;set 'Power-on' flag & timer
 
 
 
 
 
 Subroutine - Go to Yellow Alert
 
 ;length of time strobe is to remain on
 
 
 ;flag interrupt 
             service routine (ISR) to handle
 ;turn on strobe light.
 
 ;time interval to turn Siren 
             on
 
 ;set table index - defines 
             'wailing' intervals
 ;TMR0 interrupts to 
             handle siren
 ;'verbal warning' needs only a pulse to trigger it
 
 ;tmr0 interrupts will 
             handle verbal warning
 ;start verbal warning 
             (amp should be powered
 ;up)  'barking dog' needs only a pulse to trigger
 ;it
 ;set timer
 ;start barking
 
 
 Subroutine - Go to Red Alert
 ;length of time strobe is to remain on
 
 
 ;flag 'strobe' ISR 
             handling
 ;turn on strobe light.
 ;start with short pulse (Load Buzzer)
 
 ;number of pulses to generate
 ;count-down timer
 ;so tmr0 interrupts 
             will handle buzzer
 ;start with buzzer off
 ;barking dog module needs only need a pulse to
 ;start it
 ;set timer
 ;start barking (amp 
             should be powered up by ;now)
 
 
 Subroutine - Set Alarm 
             Disabled
 
 
 ;set Alarm state to 
             disabled
 ;turn off anything that is on
 ;turn off anything that is on
 
 ;set green LED  -  ON
 
 ;turn off amplifier
 
 
 ;Set automatic re-arm alarm timer to 4 hours
 ;9 minutes intervals per count here
 
 
 
 Subroutine - Turn on Debounce
 
 
 ;set Debounce interval
 ;start the Debounce 
             timer
 |