加载程序后数码管,无显示,30--32H存放秒。分。时。经BCD转化,秒数值放在40H,41H。分放在43,44.时放在46,47H。//42H,45H
放#10,对应表格DB第十一个数,数码管显示——,K1 ,K1调分和时
K1 BIT P1.0
K2 BIT P1.1
ORG 0000H
AJMP START
ORG 000BH
AJMP DS0
ORG 0030H
START: CLR A
MOV R1,#7FH //初始化清零
CL: MOV @R1,A
DJNZ R1,CL
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
SETB EA //开定时中断0
SETB ET0
SETB TR0
MOV R2,#14H //计时次数
MOV 42H,#10 // 显示--的DB位置
MOV 45H,#10 // 显示--的DB位置
MAIN: LCALL KEY
LCALL ZH //转化
LCALL DIS //调显示
AJMP MAIN
KEY: JNB K1,KEY1 //分。时调时
JNB K2,KEY2
RET
KEY1: LCALL DEL
JB K1,KEYEND //分加一
INC 31H
MOV A,31H
CJNE A,#60,KEYEND
MOV 31H,#00H
KEYEND: RET
KEY2: LCALL DEL
JB K2,KEYEND //时加一
INC 32H
MOV A,32H
CJNE A,#60,KEYEND
MOV 32H,#00H
RET
DIS: MOV R0,#40H //显示放置初地址
MOV 36H,#7FH //秒钟位码地址
MOV R4,#08H //显示次数
DIS1: MOV A,@R0
MOV DPTR,#DUAN
MOVC A,@A+DPTR
MOV P0,A
SETB P2.2
CLR P2.2
MOV A,36H
MOV P0,A
SETB P2.3
//LCALL DEL
CLR P2.3
LCALL DEL
INC R0
RR A
MOV 36H,A
DJNZ R4,DIS1
RET
ZH: MOV R0,#30H
MOV R3,#03H //时分秒转化,秒钟由30H转到40 41,分由31转到43 44,
MOV R1,#40H //时由32H转到46H 47H
ZH1: MOV A,@R0
MOV B,#10
DIV AB
XCH A,B
MOV @R1,A
INC R1
MOV @R1,B
INC R0
INC R1
INC R1
DJNZ R3 ,ZH1
RET
DS0: PUSH ACC
PUSH PSW
//CLR ET0
CLR TR0
MOV TH0,#3CH
MOV TL0,#0B0H
SETB TR0
DJNZ R2,TC
MOV R2,#14H
INC 30H
MOV A,30H
CJNE A,#60,TC
MOV 30H,#00H
INC 31H
MOV A,31H
CJNE A,#60,TC
MOV 31H,#00H
INC 32H
MOV A,32H
CJNE A,#24,TC
MOV 32H,#00H
MOV 31H,#00H
MOV 30H,#00H
TC: POP PSW
POP ACC
REti
DUAN: DB 3fH,06H,5bH,4fH,66H,6dH,7dH,07H,7fH,6fH,40H
DEL: MOV R7,#50
DEL1: MOV R6,#100
DJNZ R6,$
DJNZ R7,DEL1
RET
END
|