51单片机汇编键盘中断扫描程序,按键没有反应 求大神指点用的是外部中断0,键盘端口行为p1.5 p1.6 p1.7

ORG 0000H
AJMP MAIN
ORG 0003H
AJMP SERVE

MAIN:MOV TMOD,#01H
MOV TH0,#0F8H
MOV TL0,#30H
MOV IP,#01H
SETB EX0
SETB EA
MOV 41H,#00H
MOV 42H,#02H
MOV 43H,#04H
MOV 44H,#06H
MOV 45H,#08H
MOV 46H,#0AH
SETB P1.5
SETB P1.6
SETB P1.7
SETB TR0
MU1:MOV P2,41H
JNB TF0, MU1
CLR TF0
MOV TH0,#0F8H
MOV TL0,#30H
MU2:MOV P2,42H
JNB TF0, MU2
CLR TF0
MOV TH0,#0F8H
MOV TL0,#30H
MU3:MOV P2,43H
JNB TF0 ,MU3
CLR TF0
MOV TH0,#0F8H
MOV TL0,#30H
MU4:MOV P2,44H
JNB TF0 ,MU4
CLR TF0
MOV TH0,#0F8H
MOV TL0,#30H
MU5:MOV P2,45H
JNB TF0 ,MU5
CLR TF0
MOV TH0,#0F8H
MOV TL0,#30H
MU6:MOV P2,46H
JNB TF0, MU6
CLR TF0
MOV TH0,#0F8H
MOV TL0,#30H
AJMP MU1
SERVE:LCALL T10ms
MOV P1,#0FFH
SETB P3.4
CLR P3.7
LK1:MOV A,P1
JNB ACC.5,ONE
JNB ACC.6,ONE
JNB ACC.7,ONE
LK2:MOV P1,#0FFH
SETB P3.7
CLR P3.4
LJMP LK1
ONE:MOV A,#10H
ADD A,#02H
MOV 41H,A
KP:JNZ KP
RETI
T10ms:MOV R7,#10H
TS1:MOV R6,#0FFH
TS2:DJNZ R6,TS2
DJNZ R7,TS1
RET

END

第1个回答  2012-12-06
请上图,
相似回答