PROGRAM K ;************************************ ; written by : John Morton * ; date : 07/08/97 * ; version : 1.0 * ; file saved as : Alarm * ; for PIC16F54 * ; clock frequency : 3.82 MHz * ;************************************ ; PROGRAM FUNCTION : An alarm system which can be set or disabled. list P=16F54 include "c:\pic\p16f5x.inc" __config _RC_OSC & _WDT_ON & _CP_OFF ;============ ; Declarations : porta equ 05 portb equ 06 Post50 equ 08 Counter equ 09 org 1FF goto Start org 0 ;=========== ; Subroutines : Init clrf porta ; resets inputs and outputs clrf portb ; movlw b'0011' ; RA0 : Sensor, RA1 :Settings switch, tris porta ; RA2 : not connected, RA3 : siren movlw b'00000000' ; RB0 : green LED, RB1 : red LED tris portb ; RB2-7 : not connected movlw b'00001111' ; WDT prescaled by 128 (TMR0 not option ; prescaled) clrf Counter ; resets clock cycle counter movlw dÕ50Õ ; sets up postscaler retlw 0 ;============= ; Program Start : Start call Init Main btfsc porta, 1 ; tests setting switch goto GreenLed ; switch is high, so turn on green LED bsf portb, 1 ; switch is low, so turn on red LED TenthSecond decfsz Counter ; has 1/10th second passed? goto Continue ; decfsz Post50 ; goto Continue ; clrf portb ; it has, so turns off all LEDs Continue btfsc porta, 1 ; tests setting switch goto Waste2Cycle ; disabled, so doesn't test trigger input btfss porta, 0 ; has motion sensor has been set? goto TenthSecond ; not triggered, so loops back bsf porta, 3 ; turns on siren EndLoop clrwdt ; resets watchdog timer goto EndLoop ; constantly loops GreenLed bsf portb, 0 ; turns on green LED goto TenthSecond ; loops back to main body of program Waste2Cycle goto TenthSecond ; wastes two clock cycles END