小弟刚开始自学单片机,今天做一个例程时怎么也达不到设计的效果,我花了4个小时还是没找到问题在哪,希望各位大大帮忙看看问题在哪,谢谢!
效果描述:通过按钮的按键次数来确定流水灯的工作模式,并在数码管上显示当前的按键次数。
K1 EQU P2.0
LED EQU P0
ORG 0000H
MAIN: SETB K1
MOV LED, #00H
MOV P1, #00H
START: MOV R0, #00H
JB K1, $
JNB K1, $
INC R0
AJMP LOOP
CJNE R0, #06H, START
AJMP MAIN
LOOP: MOV A, R0
CJNE A, #01H, WW1
LCALL YY1
WW1: CJNE A, #02H, WW2
LCALL YY2
WW2: CJNE A, #03H, WW3
LCALL YY3
WW3: CJNE A, #04H, WW4
LCALL YY4
WW4: CJNE A, #05H, WW5
LCALL YY5
WW5: RET
YY1: MOV DPTR, #TAB1
MOV P1, #30H
LCALL SHOW
YY2: MOV DPTR, #TAB2
MOV P1, #5BH
LCALL SHOW
YY3: MOV DPTR, #TAB3
MOV P1, #4FH
LCALL SHOW
YY4: MOV DPTR, #TAB4
MOV P1, #66H
LCALL SHOW
YY5: MOV DPTR, #TAB5
MOV P1, #6DH
LCALL SHOW
SHOW: MOV R1, #08H
MOV R2, #00H
SH: MOV A, R2
MOVC A, @A+DPTR
MOV LED, A
INC R2
LCALL DELAY
LCALL DELAY
LCALL DELAY
JNB K1, LOOP
DJNZ R1, SH
AJMP SHOW
DELAY: MOV R6, #00H
MOV R7, #00H
NOP
NOP
DJNZ R7, $
DJNZ R6, $
RET
TAB1: DB 01111110B, 00111100B, 00011000B, 00000000B, 00011000B, 00111100B, 01111110B, 11111111B
TAB2: DB 10000001B, 11000011B, 11100111B, 11111111B, 11100111B, 11000011B, 10000001B, 00000000B
TAB3: DB 11111110B, 11111100B, 11111000B, 11110000B, 11100000B, 11000000B, 10000000B, 00000000B
TAB4: DB 00000001B, 00000011B, 00000111B, 00001111B, 00011111B, 00111111B, 01111111B, 11111111B
TAB5: DB 10000001B, 11000011B, 11100111B, 11111111B, 11100111B, 11000011B, 10000001B, 00000000B
END
单键多模式流水灯(图).doc
(39.5 KB, 下载次数: 8)
|