protues仿真时LED显示一直在跳动 ,百度搜了一下说可能是延时出现问题 可是怎么改都不好使,只是将跳动的形式变了变下面是程序
DISPBUF EQU 30H
ORG 0000H
START:MOV DISPBUF,#0C0H
MOV DISPBUF+1,#0C0H
MOV DISPBUF+2,#0C0H
MOV DISPBUF+3,#0C0H
MOV 37H,#00H
MOV 27H,#00H
MOV 26H,#00H
MOV 25H,#00H
MOV 24H,#00H
MOV 23H,#00H
MOV R3,#00H
MOV R5,#00H
MOV R4,#00H
LOOP: LCALL KEY
MOV R6,27H
CJNE R6,#00H,START
MOV R6,26H
CJNE R6,#00H,FA
LCALL CONV
FA:LCALL DISPSCAN
SJMP LOOP
KEY:MOV P2,#0FH
MOV A,P2
ANL A,#0FH
CJNE A,#0FH,K10
RET
K10:JB P2.0,K20
K11:MOV P2,#0EFH
JB P2.0,K12
CJNE R5,#00H,L1
MOV R4,#00H
INC R5
MOV R3,#1H
L1:LJMP CEND
K12: MOV P2,#0DFH
JB P2.0,K13
CJNE R5,#00H,L2
MOV R4,#00H
INC R5
MOV R3,#2H
L2:LJMP CEND
K13: MOV P2,#0BFH
JB P2.0,K14
CJNE R5,#00H,L3
MOV R4,#00H
INC R5
MOV R3,#3H
L3:LJMP CEND
K14: MOV P2,#7FH
JB P2.0,KIL
CJNE R5,#00H,L4
MOV R4,#00H
INC R5
MOV R3,#4H
KIL:LJMP KEND
L4:LJMP CEND
K20:JB P2.1,K30
K21:MOV P2,#0EFH
JB P2.1,K22
LJMP DYU
K22:MOV P2,#0DFH
JB P2.1,K23
MOV 25H,#3H
LJMP OPR
K23:MOV P2,#0BFH
JB P2.1,K24
MOV 25H,#6H
LJMP OPR
K24:MOV P2,#7FH
JB P2.1,cctv
MOV 25H,#9H
LJMP OPR
cctv:LJMP KEND
K30:JB P2.2,K40
K31: MOV P2,#0EFH
JB P2.2,K32
MOV 25H,#0H
LJMP OPR
K32:MOV P2,#0DFH
JB P2.2,K33
MOV 25H,#2H
LJMP OPR
K33:MOV P2,#0BFH
JB P2.2,K34
MOV 25H,#5H
LJMP OPR
K34:MOV P2,#7FH
JB P2.2,KEND
MOV 25H,#8H
LJMP OPR
K40:JB P2.3,KEND
K41: MOV P2,#0EFH
JB P2.3,K42
INC 27H
LJMP KEND
K42:MOV P2,#0DFH
JB P2.3,K43
MOV 25H,#1H
LJMP OPR
K43:MOV P2,#0BFH
JB P2.3,K44
MOV 25H,#4H
LJMP OPR
K44:MOV P2,#7FH
JB P2.3,KEND
MOV 25H,#7H
LJMP OPR
OPR:INC R4
CJNE R5,#00H,CHANG
CJNE R4,#2H,KBK
ZHI:MOV A,20H
MOV B,#0AH
MUL AB
MOV 20H,25H
ADD A,20H
CJNE R5,#00H,CZH
MOV 23H,A
LJMP KEND
CZH: MOV 24H,A
LJMP KEND
KEND:MOV P2,#0FH
MOV A,P2
ANL A,#0FH
CJNE A,#0FH,KEND
RET
CHANG:CJNE R4,#2H,HONG
AJMP ZHI
HONG:JNC CEND
INC R5
MOV 20H,25H
MOV 24H,25H
LJMP CEND
KBK:JNC CEND
MOV 20H,25H
MOV 23H,25H
LJMP CEND
DYU:MOV R5,#00H
MOV R4,#00H
MOV 25H,#00H
CJNE R3,#1H,S
MOV A,23H
ADD A,24H
MOV 23H,A
SJMP CEND
S:CJNE R3,#2H,S1
CLR C
MOV A,23H
CJNE A,#00H,JIANFA
MOV 23H,#0EH
SJMP CEND
JIANFA:SUBB A,24H
MOV 23H,A
SJMP CEND
S1:CJNE R3,#3H,S2
MOV A,23H
MOV B,24H
MOV A,23H
MUL AB
MOV R6,B
CJNE R6,#00H,CHENG
MOV 23H,A
SJMP CEND
S2:CJNE R3,#4,CEND
MOV A,24H
CJNE A,#00H,ZY
MOV A,#00H
SJMP CEND
ZY:MOV A,23H
MOV B,24H
DIV AB
MOV 23H,A
CEND:MOV P2,#0FH
MOV A,P2
ANL A,#0FH
CJNE A,#0FH,CEND
RET
CHENG:MOV R3,B
MOV B,#64H
DIV AB
MOV 36H,A
MOV A,B
MOV B,#0AH
DIV AB
MOV 35H,A
MOV 34H,B
MOV DPTR,#TABLE
XIAN:MOV A,34H
ADD A,#6H
MOV B,#0AH
DIV AB
MOV 25H,A
MOV 34H,B
MOV A,B
MOVC A,@A+DPTR
MOV DISPBUF,A
MOV A,35H
ADD A,#5H
ADD A,25H
MOV B,#0AH
DIV AB
MOV 25H,A
MOV 35H,B
MOV A,B
MOVC A,@A+DPTR
MOV DISPBUF+1,A
MOV A,36H
ADD A,#2H
ADD A,25H
MOV B,#0AH
DIV AB
ADD A,37H
MOV 37H,A
MOVC A,@A+DPTR
MOV DISPBUF+3,A
MOV 36H,B
MOV A,B
MOVC A,@A+DPTR
MOV DISPBUF+2,A
DJNZ R6,XIAN
MOV 26H,#1H
AJMP CEND
CONV:CJNE R5,#02H,BEI
MOV A,24H
AJMP JING
BEI:MOV A,23H
JING:MOV B,#64H
DIV AB
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV DISPBUF+2,A
MOV A,B
MOV B,#0AH
DIV AB
MOVC A,@A+DPTR
MOV DISPBUF+1,A
MOV A,B
MOVC A,@A+DPTR
MOV DISPBUF,A
RET
DISPSCAN:MOV R0,#DISPBUF
MOV R2,#4H
MOV A,#1H
SC:PUSH ACC
MOV A,@R0
MOV P1,A
POP ACC
MOV P0,A
LCALL DELAY1
RL A
INC R0
DJNZ R2,SC
MOV P0,#1H
RET
DEL12:MOV R6,#1EH
DEL2:MOV R7,#64H
DEL1:DJNZ R7,DEL1
DJNZ R6,DEL2
RET
MOV R6,#10
DELAY1:MOV R7,#100
DELAY2:DJNZ R7,DELAY2
DJNZ R6,DELAY1
RET
TABLE:DB 0C0H,0F9H,0A4H,0B0H,99H
DB 92H,82H,0F8H,80H,90H
DB 88H,83H,0C6H,0A1H,86H
DB 8EH
END
|