Program K : ;************************************ ; written by : John Morton * ; date : 07/08/97 * ; version : 1.0 * ; file saved as : Alarm * ; for PIC54 * ; clock frequency : 2.4576 MHz * ;************************************ ; PROGRAM FUNCTION : An alarm system which can be set or disabled. list P=16C54 include "c:\pic\p16c5x.inc" ;============ ; Declarations : porta equ 05 portb equ 06 Post256 equ 08 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 Post256 ; sets up first 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 movfw TMR0 ; is TMR0 at 0 ? btfss STATUS, Z ; goto Continue ; incf TMR0 ; decfsz Post256 ; goto Continue ; clrf portb ; it has, so turns off all LEDs Continue btfsc porta, 1 ; tests setting switch goto TenthSecond ; disabled, so doesn't test trigger input btfss porta, 0 ; tests to see whether 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. END