汇编基于单片机的方波发生器 四个按键四个频率
时间:10-02
整理:3721RD
点击:
分别产生50,30,20,10Hz四种频率信号通过蜂鸣器的响声和继电器的通断速度来判断。四个按键分别对应一种频率,可互相切换。 p3.0-p3.3接按键,p2.0接蜂鸣器,p2.5接继电器
我的程序怎么加消抖程序段
ORG 0000H
LJMP PPP
ORG 000BH
LJMP T0INT
ORG 0030H
PPP: MOV A,P3
CJNE A,#0FFH,ST1
SJMP PPP
ST1: MOV TMOD,#01H
MOV TH0,#0ECH
MOV TL0,#78H
SETB EA
SETB ET0
SETB TR0
MOV 30H,#02H
MOV R7,30H
SJMP $
T0INT: MOV TH0,#0ECH
MOV TL0,#78H
DJNZ R7,T0KEY
CPL P1.3
CPL P2.0
CPL P2.5
MOV R7,30H
T0KEY: MOV A,#0FFH
MOV P3,A
MOV A,P3
JNB ACC.0,KEY1
JNB ACC.1,KEY2
JNB ACC.2,KEY3
JNB ACC.3,KEY4
RETI
KEY1: MOV 30H,#02H
RETI
KEY2: MOV 30H,#03H
RETI
KEY3: MOV 30H,#05H
RETI
KEY4: MOV 30H,#0AH
RETI
END
我的程序怎么加消抖程序段
ORG 0000H
LJMP PPP
ORG 000BH
LJMP T0INT
ORG 0030H
PPP: MOV A,P3
CJNE A,#0FFH,ST1
SJMP PPP
ST1: MOV TMOD,#01H
MOV TH0,#0ECH
MOV TL0,#78H
SETB EA
SETB ET0
SETB TR0
MOV 30H,#02H
MOV R7,30H
SJMP $
T0INT: MOV TH0,#0ECH
MOV TL0,#78H
DJNZ R7,T0KEY
CPL P1.3
CPL P2.0
CPL P2.5
MOV R7,30H
T0KEY: MOV A,#0FFH
MOV P3,A
MOV A,P3
JNB ACC.0,KEY1
JNB ACC.1,KEY2
JNB ACC.2,KEY3
JNB ACC.3,KEY4
RETI
KEY1: MOV 30H,#02H
RETI
KEY2: MOV 30H,#03H
RETI
KEY3: MOV 30H,#05H
RETI
KEY4: MOV 30H,#0AH
RETI
END