XDJM:
我在Protues下学习单片机,编了一个小程序,但键盘老是不能正常工作:
1)只有1/4/7/*这四个键有反应,但是键值不对,按键1/4/7/*,数码管确显示的3/6/9/0
2)除了1/4/7/*四个键有反应外,其它键都没有反应。
请大家帮我看看
谢谢了!!
ORG 0000H
AJMP MAIN
ORG 0030H
MAIN: LCALL SCAN_KEY
JZ MAIN
LCALL DEL10MS
LCALL SCAN_KEY
JZ MAIN
MOV P3,#0CFH
JNB P3.0,L3
JNB P3.1,L6
JNB P3.2,L9
MOV P3,#0AFH
JNB P3.0,L2
JNB P3.1,L5
JNB P3.2,L8
JNB P3.3,L0
MOV P3,#07FH
JNB P3.0,L1
JNB P3.1,L4
JNB P3.2,L7
AJMP MAIN
L0: MOV A,#00H
AJMP GOON
L1: MOV A,#01H
AJMP GOON
L2: MOV A,#02H
AJMP GOON
L3: MOV A,#03H
AJMP GOON
L4: MOV A,#04H
AJMP GOON
L5: MOV A,#05H
AJMP GOON
L6: MOV A,#06H
AJMP GOON
L7: MOV A,#07H
AJMP GOON
L8: MOV A,#08H
AJMP GOON
L9: MOV A,#09H
AJMP GOON
GOON: MOV 30H,A
MOV DPTR,#DIS_TAB
MOVC A,@A+DPTR
MOV P2,A
MOV A,30H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV DPTR,#DIS_TAB
PUSH ACC
ANL A,#0FH
MOVC A,@A+DPTR
MOV P1,A
POP ACC
SWAP A
ANL A,#0FH
MOVC A,@A+DPTR
MOV P0,A
LCALL DEL10MS
LJMP MAIN
ORG 0200H
SCAN_KEY: MOV P3,#07H
MOV A,P3
ORL A,#0F0H
CPL A
RET
ORG 0250H
DEL10MS: MOV R5,#0BH
F1: MOV R7,#02H
F2: MOV R6,#0FFH
F3: DJNZ R6,F3
DJNZ R7,F2
DJNZ R5,F1
RET
ORG 0300H
TAB: DB 00H,01H,04H,09H,016H
DB 025H,036H,049H,064H,081H
ORG 0350H
DIS_TAB: DB 0C0H,0F9H,0A4H,0B0H
DB 099H,092H,082H,0F8H
DB 080H,090H,088H,083H
DB 0C6H,0A1H,086H,08EH
END
Protues schematic: |