求助,关于时钟程序
源程序是这样的,显示的时候,走5-6秒就不能正确显示了,求助各位高手帮我看下Time0 Equ -1000
Disport Equ 0000H
Csport Equ 2000H
DisBuf Equ 79H;...7EH
Sec1000Chg Bit 00H
Sec100Chg Bit 01H
Csave Bit 20H
Sec1000 Data 60H
Sec100 Data 61H
Second Data 62H
Minute Data 63H
Hour Data 64H
Asave Data 6AH
Disptr Data 6BH
Csptr Data 6CH
;-------------------------------------------------------
ORG 0000H
AJMP MAIN
;-------------------------------------------------------
ORG 000BH
AJMP TIME
;-------------------CTC0------------------------------
TIME: Mov Tl0,#Low(Time0)
Mov Th0,#High(Time0)
Mov Asave,A
Mov Csave,C
Setb Sec1000Chg
Djnz Sec1000,QTime
Mov Sec1000,#10
Setb Sec100Chg
Djnz Sec100,QTime
Mov Sec100,#100
Inc Second
Mov A,Second
Cjne A,#60,QTime
Mov Second,#0
Inc Minute
Mov A,Minute
Cjne A,#60,QTime
Mov Minute,#0
Inc Hour
Mov A,Hour
Cjne A,#60,QTime
Mov Hour,#0
QTime: Mov A,Asave
Mov C,Csave
RetI
;--------------------------------------------------------
Timeplay: Mov R1,#DisBuf
Mov A,Second
Acall Timeloop
Mov A,Minute
Acall Timeloop
Mov A,Hour
Timeloop: DA A
Mov R3,A
ANL A,#00001111B
MOV @R1,A
Inc R1
Mov A,R3
Swap A
ANL A,#00001111B
Mov @R1,A
Inc R1
Ret
;--------------------------------------------------------
DisplayS: Mov R0,Disptr
Mov A,@R0
Mov Dptr,#Distab
Movc A,@A+Dptr
Mov Dptr,#Disport
Movx @Dptr,A
Inc Disptr
Mov A,Csptr
Mov Dptr,#Csport
Movx @Dptr,A
Rl A
Jnb Acc.6,QDisplay
Initdis: Mov Disptr,#DisBuf
Mov A,#00000001B
QDisplay: Mov Csptr,A
Ret
;--------------------------------------------------------
;Readkey:
;-------------------------------------------------------
DoSec1000: Acall DisplayS
Ajmp Mainloop1
DoSec100: Acall Timeplay
Ajmp Mainloop0
;---------------Main------------------------------------
Main: Mov SP,#30H
Acall Init
Mainloop0: Jbc Sec1000Chg,DoSec1000
Mainloop1: Jbc Sec100Chg,DoSec100
Ajmp Mainloop0
;-------------------------------------------------------
Init: Mov Tmod,#00000001B
Mov TL0,#Low(Time0)
Mov Th0,#High(Time0)
Setb EA
Setb ET0
Setb TR0
Clr A
Mov Sec1000,#10
Mov Sec100,#100
Mov Second,A
Setb Sec1000Chg
Mov Disptr,#DisBuf
Mov Csptr,#00000001B
Ret
;---------------------------------------------------------
;--------------------------------------------------------
; Char: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
; Code: 00H, 01H, 02H, 03H, 04H, 05H, 06H, 07H, 08H, 09H
DisTab: DB 0C0H,0F9H,0A4H,0B0H, 99H, 92H, 82H,0F8H, 80H, 90H
; Char: 'A', 'B', 'C', 'D', 'E', 'F', '10H'
; Code: + , - , * , / , = , ON/C ,Dark
DB 0C0H,0F9H,0A4H,0B0H, 99H, 92H ,0FFH
;-------------------------------------------------------
End
proteus 仿真图
TIME.rar
(19.12 KB)