51单片机汇编语言编程独立按键
答案:1 悬赏:60 手机版
解决时间 2021-04-05 11:44
- 提问者网友:谁的错
- 2021-04-04 17:53
51单片机汇编语言编程独立按键
最佳答案
- 五星知识达人网友:患得患失的劫
- 2021-04-04 18:05
四个按键,定义如下:
KEY1 BIT P3.0
KEY2 BIT P3.1
KEY3 BIT P3.2
KEY4 BIT P3.3
按键处理程序:
;-----------------------------------
READ_KEY:
JB KEY1, K2
CALL DELAY
JB KEY1, K2
JNB KEY1, $
PUSH ACC
INC 75H
MOV A, 75H
CJNE A, #10, ZINT01
MOV 75H, #0
ZINT01:
POP ACC
JMP K_EXIT
;---------------
K2: JB KEY2, K3
CALL DELAY
JB KEY2, K3
JNB KEY2, $
PUSH ACC
INC 76H
MOV A, 76H
CJNE A, #10, ZINT01
MOV 76H, #0
ZINT01:
POP ACC
JMP K_EXIT
;---------------
K3: JB KEY3, K4
CALL DELAY
JB KEY3, K4
JNB KEY3, $
PUSH ACC
DEC 75H
MOV A, 75H
CJNE A, #255, ZINT03
MOV 75H, #9
ZINT03:
POP ACC
JMP K_EXIT
;---------------
K4: JB KEY4, K_EXIT
CALL DELAY
JB KEY4, K_EXIT
JNB KEY4, $
PUSH ACC
DEC 76H
MOV A, 76H
CJNE A, #255, ZINT04
MOV 76H, #9
ZINT04:
POP ACC
K_EXIT:
RET
;---------------
DELAY:
DJNZ R7, $
DJNZ R7, $
RET
;-----------------------------------
KEY1 BIT P3.0
KEY2 BIT P3.1
KEY3 BIT P3.2
KEY4 BIT P3.3
按键处理程序:
;-----------------------------------
READ_KEY:
JB KEY1, K2
CALL DELAY
JB KEY1, K2
JNB KEY1, $
PUSH ACC
INC 75H
MOV A, 75H
CJNE A, #10, ZINT01
MOV 75H, #0
ZINT01:
POP ACC
JMP K_EXIT
;---------------
K2: JB KEY2, K3
CALL DELAY
JB KEY2, K3
JNB KEY2, $
PUSH ACC
INC 76H
MOV A, 76H
CJNE A, #10, ZINT01
MOV 76H, #0
ZINT01:
POP ACC
JMP K_EXIT
;---------------
K3: JB KEY3, K4
CALL DELAY
JB KEY3, K4
JNB KEY3, $
PUSH ACC
DEC 75H
MOV A, 75H
CJNE A, #255, ZINT03
MOV 75H, #9
ZINT03:
POP ACC
JMP K_EXIT
;---------------
K4: JB KEY4, K_EXIT
CALL DELAY
JB KEY4, K_EXIT
JNB KEY4, $
PUSH ACC
DEC 76H
MOV A, 76H
CJNE A, #255, ZINT04
MOV 76H, #9
ZINT04:
POP ACC
K_EXIT:
RET
;---------------
DELAY:
DJNZ R7, $
DJNZ R7, $
RET
;-----------------------------------
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯