📄 alarm.txt
字号:
; mov 59h,#00h
mov 54h,#0ffh
mov 2fh,#20
disp_del1:
lcall disp
djnz 2fh,disp_del1
mov 30h,#50
lcall delay5ms
mov 2fh,#20
disp_del2:
lcall disp
djnz 2fh,disp_del2
mov 2fh,#20
disp_del3:
lcall disp
djnz 2fh,disp_del3
mov a,addresspoint
mov b,#18
mul ab
mov r6,a
clr ea
wtiic_a:
MOV MTD,#0AH
lcall IWRNBYTE
NOP
mov MRD,#51h
LCALL IRDNBYTE
MOV A,MRD
clr c
subb a,#0ah
jz addresspoint_11
ajmp wtiic_a
addresspoint_11: setb ea
mov a,addresspoint
cjne a,#max,addp_inc
addp_1:
mov addresspoint,#1
ljmp delete_out
addp_inc:
inc addresspoint
delete_out:
setb firstflag1
MOV 21H,#0FFH
mov 54h,#0ffh
mov 55h,#10h
mov 56h,#10h
mov 57h,#10h
mov 58h,#10h
mov 59h,#00h
;setb es
setb ea
mov a,#10h
lcall disp_seg
RET
;===================================定时器0中断程序==============================
time0:
push 00h
push acc
push psw
CLR C
MOV A,7fh
ADD A,#01H
MOV 7fh,A
MOV A,7eh
ADDC A,#00H
MOV 7eh,A
MOV R0,7fh
CJNE R0,#00H,OVER000
MOV R0,7eh
CJNE R0,#01H,OVER000
setb time_out
mov 7eh,#00h
mov 7fh,#00h
mov th0,#3ch
mov tl0,#0b0h
clr tr0
ljmp tout
OVER000:
mov th0,#3ch
mov tl0,#0b0h
clr time_out
setb tr0
tout: pop psw
pop acc
pop 00h ;保存r0
cpl p3.6 ;清看门?
reti
;===================================定时器0中断程序==============================
time1:
push 00h
push acc
push psw
CLR C
MOV A,7dh
ADD A,#01H
MOV 7dh,A
MOV R0,7dh
CJNE R0,#09H,OVER222
SETB time_out1
mov 7dh,#00h
mov th1,#3ch
mov tl1,#0b0h
clr tr1
ljmp tout1
OVER222:
mov th1,#3ch
mov tl1,#0b0h
clr time_out1
setb tr1
tout1: pop psw
pop acc
pop 00h ;保存r0
reti
;===============================int1 中断===========================================
INTPT1:
cpl p3.6 ;清看门狗
lcall beep
MOV 21H,#0FFH
CLR LED3
MOV A,21H
mov sbuf,a
jnb ti,$
clr ti
;=========================================================
mov a,37h
mov b,#18
mul ab
mov 3Ah,a
clr ea
MOV r6,3AH
;mov 30h,#60
;lcall delay10ms
mov MRD,#51h
LCALL IRDNBYTE
setb ea
MOV A,MRD
cjne a,#0ah,again1
mov a,37h
cjne a,#max,dailnext
lcall handfree
ljmp int1out
dailnext:
inc 37h
lcall beeplong
ljmp INTPT1
again:
INC 3AH
MOV r6,3AH
clr ea
mov MRD,#51h
LCALL IRDNBYTE
MOV A,MRD
setb ea
cpl p3.6 ;清看门狗
cjne a,#0ah,next ;是#号键吗
ljmp again_out
;========================开始拨号==========================
again1:
;MOV 30H,#30
;LCALL delay10ms
SETB mute
SETB ON_LINE
MOV 30H,#50
LCALL delay10ms
MOV 2dH,#00H
mov 39h,#64h
agains:
mov 30h,#01h
lcall delay10ms
jb p_int0,nexti
inc 2dh
nexti:
cpl p3.6 ;清看门狗
djnz 39h,agains
mov a,2dh
subb a,#90
jnc next
nop
nop
ljmp localwarning ;非低点评拨号因
next:
clr dtmf_ce
mov a,MRD
lcall out_dtmf
mov 30h,#20
lcall delay10ms
setb dtmf_ce
mov 30h,#30
lcall delay10ms
cpl p3.6 ;清看门狗
LJMP again
;=========语音监测======================================================
again_out:
cpl p3.6 ;清看门狗
mov 38h,#00h
mov 39h,#064h
mov 35h,#00h
int00:
mov 34h,#00h
againi0:
mov 30h,#0ah
lcall delay10ms
jnb P3.2,adcount
inc 35h
ljmp out
adcount:
inc 34h
mov 35h,#00h
cpl p3.6 ;清看门狗
djnz 39h,againi0
ljmp handfree1
;------------------------------
out: mov a,34h
subb a,#0eh
jnc oncemore
mov a,34h
subb a,#4
jnc ackvoice
cpl p3.6 ;清看门狗
mov a,34h
subb a,#4
jnc oncemore
mov a,34h
subb a,#2
jc onceagain
inc 38h
mov a,38h
CLR C
subb a,#02h ;03h
jz gohandfree ;检测到忙音
onceagain:
mov a,35h
clr c
subb a,#45
jnc gohandfree
oncemore:
JNB p_relax,rept0
MOV 30H,#16H
LCALL delay10ms
JNB p_relax,rept0
MOV 30H,#16H
LCALL delay10ms
JNB p_relax,rept0
setb relax_flag
lcall handfree
ljmp int1out
rept0:
cpl p3.6 ;清看门狗
ljmp int00
gohandfree:
ljmp handfree1
;===============================================================================================================
ackvoice:
lcall beep
MOV 2dH,#00H
mov 2eh,#00H
mov 39h,#0a0h
againss:
mov 30h,#0ah
lcall delay10ms
jnb P3.2,nextii
inc 2dh ;检测高电平
mov 2eh,#00h
mov a,2dh
clr c
subb a,#45
jnc playmusic
ljmp oncemore1
nextii: ;检测低电平
mov 2dh,#00h
inc 2eh
mov a,2eh
clr c
subb a,#3 ;3d 2d
jc oncemore1
mov 30h,#15 ;100d 250d ; 15d
lcall delay10ms
jb P3.2,handfree1 ;检测到忙音
mov 2eh,#00h
oncemore1:
JNB p_relax,rept1
MOV 30H,#16H
LCALL delay10ms
JNB p_relax,rept1
MOV 30H,#16H
LCALL delay10ms
JNB p_relax,rept1
setb relax_flag
lcall handfree
ljmp int1out
rept1:
cpl p3.6 ;清看门狗
djnz 39h,againss
ljmp handfree1
playmusic:
nop
clr mute
setb p_play
SETB p_record
mov r2,#00h
mov r0,#64h
busyloop1:
mov r1,#0ah
busyloop:
mov 30h,#1
lcall delay10ms
jb P3.2,oncemore3
inc r2
mov a,r2
clr c
subb a,#20 ;30d
jc oncemore2
mov 30h,#25 ;06d
lcall delay10ms
jb P3.2,handfree1
oncemore3:
mov r2,#00h
oncemore2:
JNB p_relax,rept2
MOV 30H,#16H
LCALL delay10ms
JNB p_relax,rept2
MOV 30H,#16H
LCALL delay10ms
JNB p_relax,rept2
setb relax_flag
lcall handfree
ljmp int1out
rept2:
cpl p3.6 ;清看门狗
djnz r1,busyloop
djnz r0,busyloop1
handfree1:
clr p_play
lcall handfree
CPL P3.6
;37h中存放电话个数
mov a,37h
cjne a,#max,int1next
ljmp int1out
int1next:
inc 37h
ljmp INTPT1
localwarning:
setb P3.4
mov 39h,#60
localw1:
mov r4,#0ah
localw:
mov 30h,#0ah
lcall delay10ms
JNB p_relax,repeat0
MOV 30H,#16
LCALL delay10ms
JNB p_relax,repeat0
MOV 30H,#16
LCALL delay10ms
JNB p_relax,repeat0
setb relax_flag
lcall handfree
ljmp int1out
repeat0:
djnz r4,localw
CPL P3.6
djnz 39h,localw1
int1out:
setb p1.1
clr P3.4
SETB EX1
RETI
handfree:
lcall beeplong
clr on_line
MOV A,#0FFH
mov sbuf,a
jnb ti,$
clr ti
mov 30h,#50
lcall delay10ms
ret
;==================================显示子程序===============================
disp:
push acc
push psw
push 00h
mov a,54h
cjne a,#0ffh,mout1 ;if keyflag=1
ljmp mout
mout1:
cjne a,#0ah,mout2
mov 54h,#10h
mout2:
inc 59h
mov r0,59h
cjne r0,#1,disp2
mov 58h,57h
mov 55h,54h
ljmp mout
disp2:
cjne r0,#2,disp3
mov 56h,55h
mov 55h,54h
ljmp mout
disp3:
cjne r0,#3,disp4
mov 57h,56h
mov 56h,55h
mov 55h,54h
ljmp mout
disp4:
mov 58h,57h
mov 57h,56h
mov 56h,55h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -