键控门铃程序
;***** 通过1*4按键的第3号键按下可听到门铃的声音
T5Hz EQU 30H
T7HZ EQU 31H
T05SA EQU 32H
T05SB EQU 33H
FLAG BIT 00H
STOP BIT 01H
SP1 BIT P1.0
ORG 0000H
LJMP START
ORG 000BH
LJMP INT_T0
START: MOV TMOD,#02H
MOV TH0,#06H
MOV TL0,#06H
SETB ET0
SETB EA
NSP: JB SP1,NSP
LCALL DELY10MS
JB SP1,NSP
SETB TR0
MOV T5HZ,#00H
MOV T7HZ,#00H
MOV T05SA,#00H
MOV T05SB,#00H
CLR FLAG
CLR STOP
JNB STOP,$
LJMP NSP
DELY10MS: MOV R6,#20
D1: MOV R7,#248
DJNZ R7,$
DJNZ R6,D1
RET
INT_T0:INC T05SA
MOV A,T05SA
CJNE A,#100,NEXT
MOV T05SA,#00H
INC T05SB
MOV A,T05SB
CJNE A,#20,NEXT
MOV T05SB,#00H
JB FLAG,STP
CPL FLAG
LJMP NEXT
STP: SETB STOP
CLR TR0
LJMP DONE
NEXT: JB FLAG,S5HZ
INC T7HZ
MOV A,T7HZ
CJNE A,#03H,DONE
MOV T7HZ,#00H
CPL P3.7
LJMP DONE
S5HZ: INC T5HZ
MOV A,T5HZ
CJNE A,#04H,DONE
MOV T5HZ,#00H
CPL P3.7
LJMP DONE
DONE: RETI
END