2019-07-15 09:06发布
blackwinter 发表于 2017-12-25 14:42 谢谢,能否详细说说?
王栋春 发表于 2017-12-25 14:43 原来遇到过LCD显示屏损坏的故障也是这种情况
人中狼 发表于 2017-12-25 16:10 最好把代码贴上来,下载是要扣积分的
最多设置5个标签!
原来遇到过LCD显示屏损坏的故障也是这种情况
但这是仿真,应该不会出现这种问题吧,我觉得是不是电路连接或者参数设置出现问题。
S_SET BIT P1.0
M_SET BIT P1.1
H_SET BIT P1.2
RESET BIT P1.3
D_SET BIT P1.4
YUE_SET BIT P1.5
Y_SET BIT P1.6
RS BIT P2.4
RW BIT P2.5
EN BIT P2.6
SJ EQU P0
SECOND EQU 30H
MINUTE EQU 31H
HOUR EQU 32H
TCNT EQU 34H
YEAR_H EQU 35H
YEAR_L EQU 36H
MONTH EQU 37H
DAT EQU 38H
ORG 00H
SJMP START
ORG 0BH
LJMP INT_T0
START:
MOV HOUR,#0
MOV MINUTE,#0
MOV SECOND,#0
MOV TCNT,#0
MOV YEAR_H,#20
MOV YEAR_L,#17
MOV MONTH,#0
MOV DAT,#0
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
MOV IE,#82H
SETB TR0
A1: LCALL DISPLAY
MOV P1,#0FFH
JNB S_SET,S1
JNB M_SET,S2
JNB H_SET,S3
JNB D_SET,S4
JNB YUE_SET,T5
JNB Y_SET,T6
JNB RESET,START
LJMP A1
T5: LJMP S5
T6: LJMP S6
S1: LCALL DELAY
JB S_SET,A1
INC SECOND
LCALL DISPLAY
MOV A,SECOND
CJNE A,#60,J0
MOV SECOND,#0
LJMP K1
J0:JB S_SET,A1
LCALL DISPLAY
SJMP J0
S2: LCALL DELAY
JB M_SET,A1
K1: INC MINUTE
MOV A,MINUTE
CJNE A,#60,J1
MOV MINUTE,#0
LJMP K2
J1:JB M_SET,A1
LCALL DISPLAY
SJMP J1
S3: LCALL DELAY
JB H_SET,A1
K2: INC HOUR
MOV A,HOUR
CJNE A,#24,J2
MOV HOUR,#0
LJMP K3
J2:JB H_SET,V6
LCALL DISPLAY
SJMP J2
V6:LJMP A1
S4: LCALL DELAY
JB D_SET ,V7
K3: INC DAT
MOV A,DAT
CJNE A,#31,J3
MOV DAT,#0
LJMP K4
V7:LJMP A1
J3:JB D_SET,V1
LCALL DISPLAY
SJMP J3
V1:LJMP A1
S5: LCALL DELAY
JB YUE_SET ,V2
K4: INC MONTH
MOV A,MONTH
CJNE A,#12,J4
MOV MONTH,#0
LJMP K5
V2:LJMP A1
J4:JB YUE_SET,V3
LCALL DISPLAY
SJMP J4
V3:LJMP A1
S6: LCALL DELAY
JB Y_SET ,V4
K5: INC YEAR_L
MOV A,YEAR_L
CJNE A,#99,J5
MOV YEAR_L,#0
INC YEAR_H
MOV A,YEAR_H
CJNE A,#99,J5
MOV YEAR_H,#0
LJMP A1
V4:LJMP A1
J5:JB Y_SET,V5
LCALL DISPLAY
SJMP J5
V5:LJMP A1
INT_T0: MOV TH0,#3CH
MOV TL0,#0B0H
INC TCNT
MOV A,TCNT
CJNE A,#20,RETUNE
INC SECOND
MOV TCNT,#0
MOV A,SECOND
CJNE A,#60,RETUNE
INC MINUTE
MOV SECOND,#0
MOV A,MINUTE
CJNE A,#60,RETUNE
INC HOUR
MOV MINUTE,#0
MOV A,HOUR
CJNE A,#24,RETUNE
INC DAT
MOV HOUR,#0
MOV TCNT,#0
MOV A,DAT
CJNE A,#31,RETUNE
INC MONTH
MOV DAT,#0
MOV A,MONTH
CJNE A,#12,RETUNE
INC YEAR_L
MOV MONTH,#0
MOV A,YEAR_L
CJNE A,#99,RETUNE
MOV YEAR_L,#0
INC YEAR_H
MOV A,YEAR_H
CJNE A,#99,RETUNE
MOV YEAR_H,#0
RETUNE:RETI
DISPLAY:LCALL initial ;是LCD初始化
LCALL DISPLAY1
MOV SJ,#01H
LCALL ENABLE
LCALL DELAY
RET
initial:MOV SJ,#38H
LCALL ENABLE
MOV SJ,#08H
LCALL ENABLE
MOV SJ,#01H
LCALL ENABLE
MOV SJ,#06H
LCALL ENABLE
MOV SJ,#0CH
LCALL ENABLE
LCALL DELAY
RET
DISPLAY1: MOV SJ,#80H
ACALL ENABLE
MOV A,YEAR_H
MOV B,#10
DIV AB
ADD A,#30H
MOV A,B
ADD A,#30H
LCALL XIESJ
MOV A,YEAR_L
MOV B,#10
DIV AB
ADD A,#30H
LCALL XIESJ
MOV A,B
ADD A,#30H
LCALL XIESJ
MOV A,#2DH
LCALL XIESJ
MOV A,MONTH
MOV B,#10
DIV AB
ADD A,#30H
LCALL XIESJ
MOV A,B
ADD A,#30H
LCALL XIESJ
MOV A,#2DH
LCALL XIESJ
MOV A,DAT
MOV B,#10
DIV AB
ADD A,#30H
LCALL XIESJ
MOV A,B
ADD A,#30H
LCALL XIESJ
MOV SJ,#0C0H
LCALL ENABLE
MOV A,HOUR
MOV B,#10
DIV AB
ADD A,#30H
LCALL XIESJ
MOV A,B
ADD A,#30H
LCALL XIESJ
MOV A,#3AH
LCALL XIESJ
MOV A,MINUTE
MOV B,#10
DIV AB
ADD A,#30H
LCALL XIESJ
MOV A,B
ADD A,#30H
CALL XIESJ
MOV A,#3AH
LCALL XIESJ
MOV A,SECOND
MOV B,#10
DIV AB
ADD A,#30H
LCALL XIESJ
MOV A,B
ADD A,#30H
LCALL XIESJ
MOV A,#73H
LCALL XIESJ
MOV A,#20H
LCALL XIESJ
ENABLE: CLR RS
CLR RW
SETB EN
LCALL DELAY
CLR EN
RET
XIESJ:
MOV SJ,A
SETB RS
CLR RW
SETB EN
LCALL DELAY
CLR EN
RET
DELAY: MOV R6,#5
D1: MOV R7,#250
DJNZ R7,$
DJNZ R6,D1
RET
END
一周热门 更多>