;r2=0是常规模式,1是校时模式,2是定时设置模式,3是误差校正模式
;r5表示当前操作数,校时时12345678分别表示时分秒年月日星期12345和67,
;r5表示当前操作数,定时时时表示路数,分表示时,秒表示分,8路只有一路亮,年表示自动关断是分还是秒,月日表示自动关断时间
;r3表示当前扫描led的路数
;60h-66h保存当前时间,30-3b保存6个数码管的显示值,40h-4fh保存8路倒计时时间,位10h-1fh表示自动关和倒计时单位。
;p0.0-0.6显示星期几。3cH-3dH分别保存上一次的分和秒,检查到分和秒不同时,对倒计时数进行减时,位3ch-3dh表示减过
;定时记录格式顺序@00h-@01H保存定时时间,@02H保存有效的星期和延时的单位,@03H-@04H保存延时的时间,@04保存第几路
;3FH保存误差误正的秒数0-25秒,每天最大修正为正负25秒,位3FH表示加强和减慢时间,3eH表示校正过。
;3eH保存当前定时的路数,2a/2b/2c/2d/2e保存定时时间/延时单位(2cH的位7)/星期/延时时间;
sclk bit p2.0
io bit p2.1
rst bit p3.7
psw5 bit 0d5H
sec data 60H
min data 61H
Hr data 62H
date data 63H
montH data 64H
daY data 65H
Year data 66H
org 00h
clr rst
jmp sta1
org 01bh
jmp t1int
sta1: mov tmod,#00100010b;t1工作方式
mov 7ch,#10
mov th1,#100
setb tr1
setb et1
setb ea
setb 54h
mov 40h,#2;年初置数
mov 41h,#0;年初置数
mov r5,#0;校时当前数
mov 3fh,#22;误差校正时间
mov 7ch,#10
; lcall init
mov 3eh,#0
mov 2ah,#00010001b
mov 2bh,#00110100b
mov 2ch,#11010101b
mov 2dh,#01010110b
mov 2eh,#01111000b
mov 8eh,#0 ;允许使用内部扩展的ram
call readfsh
mov r0,#255
movx a,@r0
mov 3fh,a ;误差校正数据
mov r0,#254
movx a,@r0
mov 27h,a ;保存了误差校正数据
mov r0,#253 ;保存初始化数据;新机必须初始化数据
movx a,@r0
cjne a,#51,clrs
jmp start
clrs:call clearam
start:jb 00h,$
setb 00h
cjne r2,#0,main0;54h确定是正常走时,还是校时,校时时时间不要走动
mov r0,#sec
mov r7,#7
setb psw5
mov p2,#0ffh
lcall rwrtc
mov a,60h
cjne a,3ch,secbt
jmp secbt0 ;秒和上次的秒是相同的,跳到检查分
secbt:mov 3ch,60h
clr 3ch ;新的一秒到来了,通知倒计时减秒
secbt0:mov a,61h
cjne a,3dh,minbt
jmp minbt0 ;分和上次的分是相同的,跳到正常主程序
minbt:mov 3dh,61h
clr 3dh ;新的一分钟到来了,通知倒计时减分
minbt0:mov a,62h ;检查当前小时3点时准备误差校正,4点00分30秒时实施误差校正工作,这时秒会有大幅的跳动
cjne a,#3,wcjz
clr 3eh ;准许误差校正
wcjz: cjne a,#4,main0
jb 3eh,main0 ;误差已经校正过就跳过
mov a,61h
cjne a,#0,main0
mov a,60h
cjne a,#00110000b,main0 ;为什么选在30秒校正误差?因为30正负25后都是一个合法的秒数,并且不产生进位和借位,程序比较好写
setb 3eh ;误差已经校正过,以防一天校正多次(输入负数后会再次进入30秒进入死循环)
jnb 3fh,wcjz1 ;看误差校正是加秒还是减秒
mov a,#30
subb a,3fh
da a
jmp wcjz2
wcjz1:mov a,#30
add a,3fh
da a
wcjz2:
inc a
dec a
da a
mov 60h,a
mov 5eh,#10001110b;解锁,保证字节可以写入
mov 5fh,#00000000b
call save
mov 5eh,#10000000b
mov 5fh,60h
call save
mov 5eh,#10001110b;写锁,防止字节补修改
mov 5fh,#10000000b
call save
main0:call disp1
call js
call hled
djnz 67h,mhled
mov 67h,#50
call key ;主循环50次后才执行一次键盘扫描程序,起到键盘消抖动效果
mhled:call hleda
mend:jmp start
t1int: push acc
push psw
mov tl1,#018h
mov th1,#0fch
soud: ;jb 59h,send;59h是禁止发声标志;5a、5b是声音响的时间长短
mov a,5ah
cjne a,#0,yyyy
setb p0.7
jmp send
yyyy: cpl p0.7
djnz 5bh,send
mov 5bh,#126
dec 5ah
send:
djnz 7eh,t1end
mov 7eh,#20
cpl 00h
tend1:djnz 7fh,t1end
mov 7fh,#100
cpl 01h
jb 01h,t1end
cpl 02h
t1end:pop psw
pop acc
reti
key:mov r7,#0 ;按键值先清零
orl p3,#01111111b
anl p3,#11111000b
mov a,p3
orl p3,#01111111b
anl p3,#10000111b
orl a,p3
orl a,#10000000b
ky0:cjne a,#11110101b,ky1
mov r7,#1
ky1:cjne a,#11101101b,ky2
mov r7,#2
ky2:cjne a,#11011101b,ky3
mov r7,#3
ky3:cjne a,#10111101b,ky4
mov r7,#4
ky4:cjne a,#11110110b,ky5
mov r7,#5
ky5:cjne a,#11101110b,ky6
mov r7,#6
ky6:cjne a,#11011110b,ky7
mov r7,#7
ky7:cjne a,#10111110b,ky8
mov r7,#8
djnz 29h,ky8
mov 29h,#1
; cjne r5,#1,ky8
cjne r2,#2,ky8
mov 5ah,#4
push acc
mov 52h,r7
call saveds
dec 3eh
mov r6,3eh
cjne r6,#0,dssz1a0
mov 3eh,#42
dssz1a0:
call readds
mov r7,52h
pop acc
;clr 04h
ky8:cjne a,#11110011b,ky9
mov r7,#9
djnz 29h,ky9
mov 29h,#1
mov 5ah,#4
clr 03h ;让闪动的数加1
clr 04h
ky9:cjne a,#11101011b,ky10
mov r7,#10
ky10:cjne a,#11011011b,ky11
mov r7,#11
ky11:cjne a,#10111011b,ky12
mov r7,#12
ky12:cjne r7,#0,kk9 ;有没有键按下,无键按下退出
jmp run
kk9: mov 55h,r7;存下按键值
clr 04h;表示run可以执行
rend:ret
run: jb 04h,rend
mov r7,55h
run0:cjne r7,#1,run1
cpl 78h
mov 5ah,#4
setb 04h
run1:cjne r7,#2,run2
cpl 79h
mov 5ah,#4
setb 04h
run2:cjne r7,#3,run3
cpl 7ah
mov 5ah,#4
setb 04h
run3:cjne r7,#4,run4
cpl 7bh
mov 5ah,#4
setb 04h
run4:cjne r7,#5,run5
cpl 7ch
mov 5ah,#4
setb 04h
run5:cjne r7,#6,run6
cpl 7dh
mov 5ah,#4
setb 04h
run6:cjne r7,#7,run7
cpl 7eh
mov 5ah,#4
setb 04h
run7:cjne r7,#8,run8
cpl 7fh
mov 5ah,#4
setb 04h
run8:cjne r7,#9,run9
mov 5ah,#4
setb 04h
clr 03h ;让闪动的数加1
run9:cjne r7,#10,run10
mov 5ah,#4
setb 04h
dec r5
cjne r5,#0,run10
mov r5,5dh
dec r5
run10:cjne r7,#11,run11
mov 5ah,#4
setb 04h
inc r5
mov a,r5
cjne a,5dh,run11
mov r5,#1
run11:cjne r7,#12,rrend
inc r2
cjne r2,#4,ms1
mov r2,#0
ms1: cjne r2,#0,ms2;常规走时模式
mov 5eh,#10001110b;写锁,防止字节补修改
mov 5fh,#10000000b
call save
mov r5,#0
call savefsh ;保存全部到FlasH
call readfsh ;保存全部到FlasH
ms2: cjne r2,#1,ms3;时间设置模式
mov 5eh,#10001110b;解锁,保证字节可以写入
mov 5fh,#00000000b
call save
mov r5,#4
mov 5dh,#8
ms3: cjne r2,#2,ms4;定时设置模式
mov r5,#1
mov 5dh,#10
mov 3eh,#1
call readds
ms4: cjne r2,#3,ms5;误差校正模式
mov r5,#1
mov 5dh,#3
ms5: mov 5ah,#4
setb 04h
rrend:
mov 29h,#5;长按键时间
ret
js: mov a,60h
anl a,#00001111b
mov 30h,a
mov a,60h
swap a
anl a,#00001111b
mov 31h,a
mov a,61h
anl a,#00001111b
mov 32h,a
mov a,61h
swap a
anl a,#00001111b
mov 33h,a
mov a,62h
anl a,#00001111b
mov 34h,a
mov a,62h
swap a
anl a,#00001111b
mov 35h,a
mov a,63h
anl a,#00001111b
mov 36h,a
mov a,63h
swap a
anl a,#00001111b
mov 37h,a
mov a,64h
anl a,#00001111b
mov 38h,a
mov a,64h
swap a
anl a,#00001111b
mov 39h,a
mov a,66h
anl a,#00001111b
mov 3ah,a
mov a,66h
swap a
anl a,#00001111b
mov 3bh,a
orl p0,#01111111b
mov a,65h
xq0: cjne a,#1,xq1
clr p0.6
xq1: cjne a,#2,xq2
clr p0.5
xq2: cjne a,#3,xq3
clr p0.4
xq3: cjne a,#4,xq4
clr p0.3
xq4: cjne a,#5,xq5
clr p0.2
xq5: cjne a,#6,xq6
clr p0.1
xq6: cjne a,#7,js1
clr p0.0
js1:cjne r2,#2,js2 ;下面显示定时设置模式的显示数据,3eH是当前路数
mov a,3eh
mov b,#10
div ab
mov 34h,b
mov 35h,a
mov a,2ah
anl a,#00001111b
mov 32h,a
mov a,2ah
swap a
anl a,#00001111b
mov 33h,a
mov a,2bh
anl a,#00001111b
mov 30h,a
mov a,2bh
swap a
anl a,#00001111b
mov 31h,a
mov 3ah,#18;
mov 3bh,#18;
mov a,2dh
anl a,#00001111b
mov 38h,a
mov a,2dh
swap a
anl a,#00001111b
mov 39h,a
mov a,2eh
anl a,#00001111b
mov 36h,a
mov a,2eh
swap a
anl a,#00001111b
mov 37h,a
anl p0,#10000000b
mov a,2ch
anl a,#01111111b
orl p0,a
mov p1,2fh
mov 2ch,a
rlc a
mov 10h,c
mov 11h,c
mov 12h,c
mov 13h,c
mov 14h,c
mov 15h,c
mov 16h,c
mov 17h,c
xq27:
xq28:
js2: cjne r2,#3,js3 ;下面显示误差校正模式的显示数据,位3fH是加或者减,3fH是误差修正值,在0-28之间
jb 3fh, js30
mov 30h,#19
mov 31h,#19
mov 32h,#19
mov 33h,#19
mov 34h,#19
mov 35h,#19
jmp js31
js30: mov 30h,#18
mov 31h,#18
mov 32h,#18
mov 33h,#18
mov 34h,#18
mov 35h,#18
js31: mov a,3fh
mov b,#10
div ab
mov 36h,b
mov 38h,b
mov 3ah,b
mov 37h,a
mov 39h,a
mov 3bh,a
js3: ret
hled:jb 01h,hd ;根据01的状态让数码管闪动
ret
hd:cjne r2,#1,hd8 ;校时模式的数码管闪动状态
hd0: cjne r5,#1,hd1
mov 35h,#17
mov 34h,#17
hd1: cjne r5,#2,hd2
mov 33h,#17
mov 32h,#17
hd2: cjne r5,#3,hd3
mov 31h,#17
mov 30h,#17
hd3: cjne r5,#4,hd4
mov 3bh,#17
mov 3ah,#17
hd4: cjne r5,#5,hd5
mov 39h,#17
mov 38h,#17
hd5: cjne r5,#6,hd6
mov 37h,#17
mov 36h,#17
hd6: cjne r5,#7,hd7
mov p0,#11111111b
hd7:
hd8: cjne r2,#2,hd18 ;定时模式的数码管闪动
hd10: cjne r5,#1,hd11
mov 35h,#17
mov 34h,#17
hd11: cjne r5,#2,hd12
mov 33h,#17
mov 32h,#17
hd12: cjne r5,#3,hd13
mov 31h,#17
mov 30h,#17
hd13: cjne r5,#4,hd14
mov 3bh,#17
mov 3ah,#17
hd14: cjne r5,#5,hd15
mov 39h,#17
mov 38h,#17
hd15: cjne r5,#6,hd16
mov 37h,#17
mov 36h,#17
hd16: mov r6,#100
cjne r5,#7,hd17
cpl p0.6
cpl p0.5
cpl p0.4
djnz r6,$
cpl p0.6
cpl p0.5
cpl p0.4
hd17: cjne r5,#8,hd17a
cpl p0.2
cpl p0.3
djnz r6,$
cpl p0.2
cpl p0.3
hd17a: cjne r5,#9,hd17b
cpl p0.1
cpl p0.0
djnz r6,$
cpl p0.1
cpl p0.0
hd17b: cjne r5,#10,hd18
hd18: cjne r2,#3,hd28 ;误差校正模式的闪动情况
hd20: cjne r5,#1,hd21
mov 35h,#17
mov 34h,#17
mov 33h,#17
mov 32h,#17
mov 31h,#17
mov 30h,#17
hd21: cjne r5,#2,hd22
mov 3bh,#17
mov 3ah,#17
mov 39h,#17
mov 38h,#17
mov 37h,#17
mov 36h,#17
hd22:
hd23:
hd28:
ret
hleda: jb 03h,hdend;根据加1键和当前状态来确定对那个数计数和保存
setb 03h
jmp sav0
hdend: ret
sav0:cjne r2,#1,sav1a ;执行校时模式的修改和保存
jmp hd0a
sav1a:jmp sav1
hd0a: cjne r5,#3,hd1a
inc 60h
mov a,60h
da a
mov 60h,a
cjne a,#01100000b,hd1aa
mov 60h,#0
hd1aa: mov 5eh,#10000000b
mov 5fh,60h
call save
hd1a: cjne r5,#2,hd2a
inc 61h
mov a,61h
da a
mov 61h,a
cjne a,#01100000b,hd2aa
mov 61h,#0
hd2aa: mov 5eh,#10000010b
mov 5fh,61h
call save
hd2a: cjne r5,#1,hd3a
inc 62h
mov a,62h
da a
mov 62h,a
cjne a,#00100100b,hd3aa
mov 62h,#0
hd3aa: mov 5eh,#10000100b
mov 5fh,62h
call save
hd3a: cjne r5,#6,hd4a
inc 63h
mov a,63h
da a
mov 63h,a
cjne a,#00110010b,hd4aa
mov 63h,#1
hd4aa: mov 5eh,#10000110b
mov 5fh,63h
call save
hd4a: cjne r5,#5,hd5a
inc 64h
mov a,64h
da a
mov 64h,a
cjne a,#00010011b,hd5aa
mov 64h,#1
hd5aa: mov 5eh,#10001000b
mov 5fh,64h
call save
hd5a: cjne r5,#4,hd6a
inc 66h
mov a,66h
da a
mov 66h,a
cjne a,#01010001b,hd6aa
mov 66h,#5
hd6aa: mov 5eh,#10001100b
mov 5fh,66h
call save
hd6a: cjne r5,#7,hd7a
inc 65h
mov a,65h
cjne a,#8,hd7aa
mov 65h,#1
hd7aa: mov 5eh,#10001010b
mov 5fh,65h
call save
hd7a: cjne r5,#8,hd8a
inc 66h
mov a,66h
da a
mov 66h,a
cjne a,#01010001b,hd8aa
mov 66h,#7
hd8aa: mov 5eh,#10001100b
mov 5fh,66h
call save
hd8a: cjne r5,#9,hd9a
inc 66h
mov a,66h
da a
mov 66h,a
cjne a,#01010001b,hd9aa
mov 66h,#7
hd9aa: mov 5eh,#10001100b
mov 5fh,66h
call save
hd9a:
sav1:cjne r2,#2,sav2 ;执行定时设置的数据修改
dssz0: cjne r5,#1,dssz1
call saveds
inc 3eh
mov a,3eh
cjne a,#43,dssz1a
mov 3eh,#1
dssz1a:call readds
dssz1:cjne r5,#2,dssz2
mov a, 2ah
inc a
da a
mov 2ah,a
cjne a,#00100101b,dssz2
mov 2ah,#0
dssz2:cjne r5,#3,dssz3
mov a, 2bh
inc a
da a
mov 2bh,a
cjne a,#01010000b,dssz3
mov 2bh,#0
dssz3:cjne r5,#4,dssz4
dssz4:cjne r5,#5,dssz5
mov a, 2dh
inc a
da a
mov 2dh,a
cjne a,#10010000b,dssz5
mov 2dh,#0
dssz5:cjne r5,#6,dssz6
mov a, 2eh
inc a
da a
mov 2eh,a
cjne a,#01100000b,dssz6
mov 2eh,#0
dssz6:cjne r5,#7,dssz7
cpl 64h
dssz7a: jb 64h,dssz7
cpl 65h
dssz7b: jb 65h,dssz7
cpl 66h
dssz7:cjne r5,#8,dssz8
cpl 62h
jb 62h,dssz8
cpl 63h
dssz8:cjne r5,#9,dssz9
cpl 60h
jb 60h,dssz9
cpl 61h
dssz9:cjne r5,#10,sav2
sav2: cjne r2,#3,sav3 ;执行误差校正设置
wcsz0:cjne r5,#1,wcsz1
cpl 3fh
wcsz1:cjne r5,#2,wcsz2
inc 3fh
mov a,3fh
cjne a,#29,wcsz2
mov 3fh,#0
wcsz2:
sav3:
ret
disp1:mov p2,#0ffh
inc 51h
mov r3,51h
ds8:cjne r3,#6,dis1
mov 51h,#0
mov r3,51h
dis1:cjne r3,#0,dis2
mov r0,#30h
call fssj
clr p2.4
dis2:cjne r3,#1,dis3
mov r0,#31h
call fssj
clr p2.6
dis3:cjne r3,#2,dis4
mov r0,#32h
call fssj
clr p2.3
dis4:cjne r3,#3,dis5
mov r0,#33h
call fssj
clr p2.7
dis5:cjne r3,#4,dis6
mov r0,#34h
call fssj
clr p2.2
dis6:cjne r3,#5,dis7
mov r0,#35h
call fssj
clr p2.5
dis7:
dipend:
ret
disp2:
fssj:
mov a,@r0
mov dptr,#tab00
movc a,@a+dptr
mov r7,#8
fs232:rlc a
mov p2.0,c
setb p2.1
clr p2.1
djnz r7,fs232
inc r0
inc r0
inc r0
inc r0
inc r0
inc r0
mov a,@r0
mov dptr,#tab11
movc a,@a+dptr
mov r7,#8
cjne r2,#0,fs2321
rlc a
mov c,02h
rrc a
fs2321:rlc a
mov p2.0,c
setb p2.1
clr p2.1
djnz r7,fs2321
edisp:ret
tab00: db 90H,0beH,85H,8cH,0aaH,0c8H,0c0H,9eH,80H,88H,82H,0e0H,0d1H,0a4H,0c1H,0c3H,0ffh,0ffh,0efh,0feh
tab11: db 90H,0FcH,0a2H,0a4H,0ccH,85H,81H,0bcH,80H,84H,88H,0c1H,93H,0e0H,83H,8bH,0ffh,0ffh,0efh,0feh
save: mov p2,#0ffh
clr rst
nop
clr sclk
nop
setb rst
nop
nop
wrrtc1a:mov r6,#8
mov a,5eh;;
clr c
wrrtc2a:clr sclk
rrc a
mov io,c
nop
setb sclk
djnZ r6,wrrtc2a
wrrtc1a1:mov r6,#8
mov a,5fh;;
clr c
wrrtc2a1:clr sclk
rrc a
mov io,c
nop
setb sclk
djnZ r6,wrrtc2a1
clr rst
nop
clr sclk
ret
rwrtc: mov b,#10000001b
jb psw5,rwrtc1
mov b,#10000000b
rwrtc1:clr sclk
nop
setb rst
mov r6,#8
mov a,b
rwrtc2:clr sclk
rrc a
mov io,c
nop
setb sclk
djnZ r6,rwrtc2
mov r6,#8
jnb psw5,rwrtc4
rwrtc3:clr sclk
nop
mov c,io
rrc a
setb sclk
djnZ r6,rwrtc3
mov @r0,a
sjmp rwrtc6
rwrtc4:mov a,@r0
rwrtc5:clr sclk
rrc a
mov io,c
nop
setb sclk
djnZ r6,rwrtc5
rwrtc6:inc r0
mov a,b
add a,#00000010b
mov b,a
clr rst
nop
clr sclk
djnZ r7,rwrtc1
ret
wrrtc: clr sclk
nop
setb rst
nop
nop
mov r7,#2
wrrtc1:mov r6,#8
mov a,@r0
clr c
wrrtc2:clr sclk
rrc a
mov io,c
nop
setb sclk
djnZ r6,wrrtc2
inc r0
djnZ r7,wrrtc1
clr rst
nop
clr sclk
ret
init: clr sclk
clr rst
mov sec,#10001110b
mov min,#00000000b
mov r0,#sec
lcall wrrtc
mov sec,#10010000b
mov min,#10100101b
mov r0,#sec
lcall wrrtc
mov sec,#10000000b
mov min,#00000000b
mov r0,#sec
lcall wrrtc
ret
readds: mov a,3eh
dec a
mov b,#6
mul ab
mov dpl,a
mov dph,b
mov r1,#2ah
mov r7,#6
re1: movx a,@dptr
mov @r1,a
inc dptr
inc r1
djnz r7,re1
ret
saveds: mov a,3eh
dec a
mov b,#6
mul ab
mov dpl,a
mov dph,b
mov r1,#2ah
mov r7,#6
sa1: mov a,@r1
movx @dptr,a
inc dptr
inc r1
djnz r7,sa1
ret
readfsh: mov r0,#0h
mov r1,#0h
staf: mov 0e3h,#20h ;从FlasH中读出已前学习存储到的代码,放到内存中,从80h-0ffh共64字节,
mov 0e4h,r1
mov 0e7h,#0
orl 0e7h,#10000000b
mov 0e5h,#1 ;FlasH字节读出
mov 0e6h,#46h
mov 0e6h,#0b9h
nop
mov 0e7h,#0
mov 0e5h,#0
mov 0e6h,#0
mov a,0e2h
movx @r0,a
inc r0
inc r1
cjne r0,#0h, staf ;全部读到内存中,以便和收到的代码进行比较,确定开关灯
mov r0,#255
movx a,@r0
mov 3fh ,a
mov r0,#254
movx a,@r0
mov 27h ,a
ret
savefsh:
clr ea
mov r1,#253
mov a,#51
movx @r1,a
mov r1,#254
mov a, 27h ;误差校正数据
movx @r1,a
mov r1,#255
mov a, 3fh ;误差校正数据
movx @r1,a
mov 0e3h,#20h
mov 0e4h,#00h
mov 0e7h,#0
orl 0e7h,#10000000b
mov 0e5h,#3 ;FlasH块擦除
mov 0e6h,#46h
mov 0e6h,#0b9h ;为什么说这些操作没有理由?因为单片机的任何操作都是将数(指令或者数据)搬来搬去,芯片设计时就是只要放上这些命令,FlasH读写功能就自动完成了。(驱动液晶、18b20测试温度、串行通信等等都是一样,别公司型号的单片机等,都是一样,放上不同的指令就完成了不同的功能,而这些都是要查相关的资料的。)
nop
mov 0e7h,#0
mov 0e5h,#0
mov 0e6h,#0
mov r0,#0
mov r1,#0
savf: mov 0e3h,#20h ;重复进行写入FlasH
mov 0e4h,r1
movx a,@r0
mov 0e2h,a
mov 0e7h,#0
orl 0e7h,#10000000b
mov 0e5h,#2 ;FlasH字节写入
mov 0e6h,#46h
mov 0e6h,#0b9h
nop
mov 0e7h,#0
mov 0e5h,#0
mov 0e6h,#0
inc r0
inc r1
cjne r0,#0h,savf ;重复循环将全部数据保存到FlasH中
setb ea
ret
clearam:
mov r1,#0
cc00: mov a,#00100100b ;bcd24
movx @r1,a
inc r1 ;1*
mov a,#00110000b ;bcd30
movx @r1,a
inc r1 ;2*
mov a,#10000000b ;单位分加上星期七天
movx @r1,a
inc r1 ;3*
mov a,#0 ;延时十位
movx @r1,a
inc r1 ;4*
mov a,#0 ;延时个位
movx @r1,a
inc r1 ;5*
mov a,#11111111b ;有哪一路需要输出,直接将高电平和p1口进行逻辑或
movx @r1,a
inc r1 ;6*
cjne r1,#252,cc00
inc r1
mov a,#51
movx @r1,a
inc r1
mov a, 27h ;误差校正数据
movx @r1,a
inc r1
mov a, 3fh ;误差校正数据
movx @r1,a
call savefsh
call readfsh
ret
end