分别产生times New Roman">50,30,20,10Hz四种频率信号通过蜂鸣器的响声和继电器的通断速度来判断。四个按键分别对应一种频率,可互相切换。 p3.0-p3.3接按键,p2.0接蜂鸣器,p2.5接继电器
我写的程序不能切换,只有一个频率10Hz,不知道哪有错误,大家帮忙指出错误改正一下吧。
ORG 0000H
LJMP START
ORG 0030H
START: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
LJMP START
ORG 0060H
KEY1:LJMP KET1
KEY2:LJMP KET2
KEY3:LJMP KET3
KEY4:LJMP KET4
ORG 0100H
KET1:MOV TMOD,#01H
MOV TH0,#0D8H
MOV TL0,#0F0H
SETB EA
SETB ET0
SETB TR0
SELF1:AJMP SELF1
LJMP START
ORG 000BH
LJMP KT1
ORG 0150H
KT1:MOV TH0,#0D8H
MOV TL0,#0F0H
CPL P2.0
//CPL P2.5
RETI
ORG 0200H
KET2:MOV TMOD,#01H
MOV TH0,#0BEH
MOV TL0,#0C4H
SETB EA
SETB ET0
SETB TR0
SELF2:AJMP SELF2
LJMP START
ORG 000BH
LJMP KT2
ORG 0250H
KT2:MOV TH0,#0BEH
MOV TL0,#0C4H
CPL P2.0
//CPL P2.5
RETI
ORG 0300H
KET3:MOV TMOD,#01H
MOV TH0,#9EH
MOV TL0,#58H
SETB EA
SETB ET0
SETB TR0
SELF3:AJMP SELF3
LJMP START
ORG 000BH
LJMP KT3
ORG 0350H
KT3:MOV TH0,#9EH
MOV TL0,#58H
CPL P2.0
//CPL P2.5
RETI
ORG 0400H
KET4:MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
SETB EA
SETB ET0
SETB TR0
SELF4:AJMP SELF4
LJMP START
ORG 000BH
LJMP KT4
ORG 0450H
KT4:MOV TH0,#3CH
MOV TL0,#0B0H
CPL P2.0
//CPL P2.5
RETI
END
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
// 我写的程序不能切换,只有一个频率10Hz,不知道哪有错误,大家帮忙指出错误改正一下吧。
ORG 0000H
LJMP START
ORG 0030H
START:MOV A,#0FFH //
MOV P3,A
MOV A,P3
MOV ACC,A //加这一句试。
JNB ACC.0,KEY1 //
JNB ACC.1,KEY2
JNB ACC.2,KEY3
JNB ACC.3,KEY4
LJMP START
ORG 0060H
KEY1:LJMP KET1
KEY2:LJMP KET2
KEY3:LJMP KET3
KEY4:LJMP KET4
ORG 0100H
KET1:MOV TMOD,#01H
MOV TH0,#0D8H
MOV TL0,#0F0H
SETB EA
SETB ET0
SETB TR0
SELF1:AJMP SELF1
LJMP START
ORG 000BH
LJMP KT1
ORG 0150H
KT1:MOV TH0,#0D8H
MOV TL0,#0F0H
CPL P2.0
//CPL P2.5
RETI
ORG 0200H
KET2:MOV TMOD,#01H
MOV TH0,#0BEH
MOV TL0,#0C4H
SETB EA
SETB ET0
SETB TR0
SELF2:AJMP SELF2
LJMP START
ORG 000BH
LJMP KT2
ORG 0250H
KT2:MOV TH0,#0BEH
MOV TL0,#0C4H
CPL P2.0
//CPL P2.5
RETI
ORG 0300H
KET3:MOV TMOD,#01H
MOV TH0,#9EH
MOV TL0,#58H
SETB EA
SETB ET0
SETB TR0
SELF3:AJMP SELF3
LJMP START
ORG 000BH
LJMP KT3
ORG 0350H
KT3:MOV TH0,#9EH
MOV TL0,#58H
CPL P2.0
//CPL P2.5
RETI
ORG 0400H
KET4:MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
SETB EA
SETB ET0
SETB TR0
SELF4:AJMP SELF4
LJMP START
ORG 000BH
LJMP KT4
ORG 0450H
KT4:MOV TH0,#3CH
MOV TL0,#0B0H
CPL P2.0
//CPL P2.5
RETI
END
一周热门 更多>