数码管是共阳极
键盘是这样的
我想依次按下12345,然后led也依次显示12345
可是哪里错了 ,我不知道
ORG 0000H
MAIN: MOV 30H, #00H
MOV 31H, #00H
MOV 32H, #00H
MOV 33H, #00H
MOV 34H, #00H ;存放值的单元清零
MOV 3CH, #10H
MOV 3BH, #08H
MOV 3AH, #04H
MOV 39H, #02H
MOV 38H, #01H ;位选信号
MOV 60H, #0C0H
MOV 61H, #0F9H
MOV 62H, #0A4H
MOV 63H, #0B0H
MOV 64H, #99H
MOV 65H, #92H
MOV 66H, #82H
MOV 67H, #0F8H
MOV 68H, #80H
MOV 69H, #90H ;赋段码初值
MOV A, #00H
MOV SP, #70H
L1:
MOV P1, #0F0H
LCALL KS1 ;查有无键闭合
CJNE A, #0FFH, LK1 ;有键闭合,消颤
LCALL XIANSHI ;调显示子程序
AJMP L1 ;没有键闭合,继续查询
LK1: LCALL YANSHI
LCALL KS1 ;再查
CJNE A, #0FFH, LK0 ;有就转处理
LCALL LK1 ;没有再查
LK0: MOV A, P1 ;判断按键是否松开
CJNE A, #0F0H, LK2
AJMP LK0
LK2: MOV A, 5DH
CJNE A, #7BH, Lk3
LJMP L70
LK3: CJNE A, #0BBH, Lk4
LJMP L60
LK4: CJNE A, #0DBH, Lk5
LJMP L50
LK5: CJNE A, #7DH, Lk6
LJMP L71
LK6: CJNE A, #0BDH, Lk7
LJMP L61
LK7: CJNE A, #0DDH, Lk8
LJMP L51
LK8: CJNE A, #7EH, Lk9
LJMP L72
LK9: CJNE A, #0BEH, Lk10
LJMP L62
LK10: CJNE A, #0DEH, Lk11
LJMP L52
LK11: CJNE A, #0B7H, Lk12
LJMP L63
LK12: CJNE A, #0E7H, Lk13
LJMP L43
LK13: CJNE A, #0EBH, Lk14
LJMP L42
LK14: CJNE A, #0EDH, Lk15
LJMP L41
LK15: CJNE A, #0EEH, Lk16
LJMP L40
LK16: CJNE A, #0D7H, Lk17
LJMP L53
LK17: CJNE A, #77H, Lk18
LJMP L73
LK18: AJMP L1
L70: MOV 37H, #01H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L60: MOV 37H, #02H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L50: MOV 37H, #03H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L71: MOV 37H, #04H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L61: MOV 37H, #05H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L51: MOV 37H, #06H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L72: MOV 37H, #07H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L62: MOV 37H, #08H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L52: MOV 37H, #09H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
L63: MOV 37H, #00H
LCALL YIWEI
LCALL XIANSHI
LJMP L1
l43: LJMP L1
L42: LJMP L1
L41: LJMP L1
L40: LJMP L1
L53: LJMP L1
L73: LJMP L1
P74: LJMP MAIN
;*************************************************************************************************
; * * *
; 查询有无键按下,若有键按下,A不全为1 * * *
; * * *
; * * *
;*************************************************************************************************
KS1: MOV P1, #0F0H ;线反转法, ;**
MOV A, P1 ;**
ANL A, #0F0H ;**
MOV B, A ;**
MOV P1, #0FH ;**
MOV A, P1 ;**
ANL A, #0FH ;**
ORL A, B ;有键按下,A不全为1 ;**
RET ;**
;*************************************************************************************************
YIWEI: MOV A, #00H
CJNE A, 30H, L8
CJNE A, 31H, L9
CJNE A, 32H, L10
CJNE A, 33H, L11
CJNE A, 34H, L12
MOV 34H, 37H
LJMP L13
L8: LJMP MAIN ;返回查询
L9: MOV 30H, 31H
MOV 31H, 32H
MOV 32H, 33H
MOV 33H, 34H
MOV 34H, 37H
LJMP L13
L10: MOV 31H, 32H
MOV 32H, 33H
MOV 33H, 34H
MOV 34H, 37H
LJMP L13
L11: MOV 32H, 33H
MOV 33H, 34H
MOV 34H, 37H
LJMP L13
L12: MOV 33H, 34H
MOV 34H, 37H
L13: RET
;*************************************************************************************************
; * * *
; 让数字显示在数码管上 * * *
; * * *
; * * *
;*************************************************************************************************
;**
;**
XIANSHI: MOV A, #00H ;**
CJNE A, 30H, L15 ;**
CJNE A, 31H, L16 ;**
CJNE A, 32H, L17 ;**
CJNE A, 33H, L18 ;**
CJNE A, 34H, L29 ;**
MOV 5EH, #01H ;**
AJMP L30 ;**
;**
L15: MOV 5EH, #05H ;**
AJMP L30 ;**
L16: MOV 5EH, #04H ;**
AJMP L30 ;**
L17: MOV 5EH, #03H ;**
AJMP L30 ;**
L18: MOV 5EH, #02H ;**
AJMP L30 ;**
L29: MOV 5EH, #01H ;判断缓存区里面有几位数字 ;**
AJMP L30 ;**
;**
;**
;**
L30: MOV R7, 5EH ;**
MOV R0, #34H ;**
MOV R1, #38H ;**
;**
L57: MOV P3, @R1 ;**
MOV A, @R0 ;**
;**
MOV 5FH, R0 ;**
MOV R0, #60H ;**
ADD A, R0 ;**
MOV R0, A ;**
;**
MOV P2, @R0 ;**
MOV R0, 5FH ;**
DEC R0 ;**
INC R1 ;**
DJNZ R7, L57 ;**
;**
RET ;**
;**
;*************************************************************************************************
YANSHI: MOV R7, #120
DL1: MOV R6, #200
DL2: DJNZ R6, DL2
DJNZ R7, DL1
RET
END
此帖出自
小平头技术问答
大哥 求指点
一下,这是我写的
阅读权限: 10
自己慢慢debug吧。
错了,又找出了错误,那可是大进步。程序员就是这样养成的。
那请问一下用proteus仿真时可以像伟福那样跟踪代码运行吗?
没有用过proteus仿真。
一周热门 更多>