;----------------------------------------------------------------------------
; I N T E R R U P T P R O G R A M M
;----------------------------------------------------------------------------
;------------------------------ Entrance ------------------------------------
TC1_OVF: ;sei ;global INT enable
push r16 ;push R16
in r16,sreg ;push sreg
push r16 ;push sreg
push r17
push r18
;------------------------------ CODE ---------------------------------
ldi r16,0xFC ;(FC -optimum)
out TCNT1H,r16 ;
ldi r16,0x17 ;
out TCNT1L,r16 ;TC1 Start from 0xFC17 (2KHz)
lds r16,PCF8583_A00 ;
sbrs r16,1 ;
rjmp TC12 ;Test ALARM
sbi portb,4 ;RELE ON
lds r17,IND_FLAG ;
tst r17 ;
brne TC11 ;Get 1/4s pulses
tst r3 ;
brne TC11 ;Test BEEP flag
ser r16 ;
mov r3,r16 ;BEEP=1
sbi portd,3 ;Set PORTD3=1
rjmp TC12 ;
TC11: clr r3 ;BEEP=0
cbi portd,3 ;CLEAR PORTD3=1
TC12:
;------------------------------ EXIT ---------------------------------------
pop r18
pop r17
pop r16 ;Pop Rx from STACK
out sreg,r16 ;Pop sreg
pop r16 ;pop R16
RETI