Automatic re-set PIC timer program for burglar alarm system

The automatic re-set timer for the crime prevention buzzer was made by using PIC12F629. It introduces the assembler program.

Automatic re-set timer for crime prevention buzzer that uses PIC12F629

The bell keeps ringing generally though the bell rings as for the crime prevention buzzer when the thief was about to enter. With this, after the fixed time, it is stopped because surroundings are troubled you and it is inconvenient. In addition, to operate even by degrees how many after it stops, the crime prevention buzzer is set again.

However, because the timer had not been found to be suitable at the production this time, multi cooking stove timer ATC12112 of National was adjusted to five minutes of the turning on mode and it used it.

Recently Because it had come to be able to use the PIC microcomputer, the timer of this ATC12112 was replaced with PIC12F629. It introduces it because it easily made it to good.

Assembler that uses PIC12F629 program

; Filename:	bell_timer.asm
; Date:		2007.08.03
; File Version:	1.0
; Bell Timer 3sec. 5min
; Author:		D.Ishikawa
	list	p=12f629		;list directive to define processor
	#include	<>	;processor specific variable definitions

	errorlevel	-302	; suppress message 302 from list file


#define	OUT_TMR	GPIO,2	;
#define	IN_P	GPIO,3	;

w_temp		EQU	0x20	;variable used for context saving 
status_temp	EQU	0x21	;variable used for context saving

TMP_CNT1		EQU 0x22
TMP_CNT2		EQU 0x23
TMP_CNT3		EQU 0x24
TMP_CNT4		EQU 0x25
	ORG	0x000	;processor reset vector
	goto	main	;go to beginning of program

	ORG	0x004	;interrupt vector location
	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

;isr code can go here or be located as a call subroutine elsewhere

	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

;these first 4 instructions are not required if the internal oscillator is not used

	call	0x3FF		;retrieve factory calibration value
	bsf	STATUS,RP0	;set file register bank to 1 
	movwf	OSCCAL		;update register with factory cal value 
	bcf	STATUS,RP0	;set file register bank to 0

;remaining code goes here

	bcf	STATUS,RP0	;set file register bank to 0
	bcf	STATUS,RP1	;set file register bank to 0

	clrf	INTCON		;

	clrf	GPIO		;

	bsf	STATUS,RP0	;
	clrf	TRISIO		;
	bsf	TRISIO,3	;

	clrf	IOC		;
	movlw	b'10000000'	;
	movwf	OPTION_REG	;

	bcf	STATUS,RP0	;

	bcf	OUT_TMR		;

	btfsc	IN_P		;
	goto	_5MIN		;

	call	DLY_500
	call	DLY_500
	call	DLY_500
	call	DLY_500
	call	DLY_500
	call	DLY_500
SET3	bsf	OUT_TMR	;
	goto	SET3

	call	DLY_5MIN
SET5	bsf	OUT_TMR	;
	goto	SET5

;Delay Routine

DLY_5MIN			;
	movlw	d'5'		;1*5=5min
	movwf	TMP_CNT4
DLY_4			;60S
	movlw	d'120'		;0.5*120=60S
	movwf	TMP_CNT3
	call	DLY_500
	decfsz	TMP_CNT3,f
	goto	DLY_3
	decfsz	TMP_CNT4,f
	goto	DLY_4

DLY_500			;500mS
	movlw	d'250'		;2mS*250=500mS
	movwf	TMP_CNT2
DLY_2			;2mS	;
	movlw	d'249'		;	(1)		1cycle=1 micro S
	movwf	TMP_CNT1		;	(1)
	nop			;	(1)
	nop			;	(1)
	nop			;	(1)
	nop			;	(1)
DLY_1			;  DLY_1 loop
	nop			;1	 1
	nop			;1	 1
	nop			;1	 1
	nop			;1	 1
	nop			;1	 1
	decfsz	TMP_CNT1,f	;1	 2
	goto	DLY_1		;2
	decfsz	TMP_CNT2,f	;	 1
	goto	DLY_2		;	(2)

;initialize eeprom locations

	ORG	0x2100
	DE	0x00, 0x01, 0x02, 0x03

	END			;directive 'end of program'

How to use of the assembler program.

Please make the file name bell_timer.asm etc. , preserve, and use it.