beep_out:
jb ha_f,ba1
mov beep,sec
setb ha_f
ba1:
mov a,beep
add a,beep_t
mov b,#60d
div ab
mov a,sec
cjne a,b,beep_out_end
setb beep_f
setb ha_over
clr ha_f
beep_out_end:
ret
timer_int:
MOV T_1S,#TIMER_no
mov beep_t,#15d
mov year ,#01d
mov mon , #011d
mov day , #06d
mov hour ,#13d
mov min , #00d
mov sec , #00d
mov r7,#16
mov dptr ,#al_asc
mov r0,#al1_h
al_read:
clr a
movc a,@a+dptr
mov @r0,a
inc r0
inc dptr
djnz r7,al_read
ret
;************************************
beep_timer:
mov led1,#blk_led
mov led2,#b_led
mov led3,#blk_led
mov a,beep_t
acall bcd_8
mov led4,a
mov led5,b
jb fl_250ms,ft1
mov led4,#blk_led
mov led5,#blk_led
ft1:
ret
time_12:
mov dptr,#asc_12
mov a,hour
rl a
movc a,@a+dptr
mov led2,a
jnz iu2
mov led2,#blk_led
iu2:
inc dptr
mov a,hour
rl a
movc a,@a+dptr
jb fl_500ms ,iu1
add a,#10d
iu1:
mov led3,a
;*************************************** min to led
acall led_min
time_24_end:
ret
asc_12:
db 11d,2d,21d,1d,21d,2d,21d,3d,21d,4d,21d,5d,21d,6d,21d,7d
db 21d,8d,21d,9d,11d,0d,11d,1d
db 1d,2d,0d,1d,0d,2d,0d,3d,0d,4d,0d,5d,0d,6d,0d,7d,0d,8d,0d,9d
db 1d,0,1d,1d
clock:
;********************************
mov a,sec
cjne a,#60d,clock_end;!!!!!!!!!!!!!!!!!!!!!!
mov sec,#00h
inc min
;**********
clr ha_over ;2001.5.6
mov a,min
cjne a,#60d,clock_end
mov min,#00h
inc hour
mov a,hour
cjne a,#24d,clock_end
mov hour,#00h
mov a,mon
xrl a,#02d
jnz mm_1
mov dptr,#year_d
mov a, year
movc a,@a+dptr
sjmp mm_2
mm_1:
mov a,mon
dec a
mov dptr,#mou_12
movc a,@a+dptr
mm_2:
mov b,a
inc b
inc day ;***************day+1
mov a,day
cjne a ,b ,clck_end
sjmp clck1
clck_end:
jc clock_end
clck1:
mov day,#01h
inc mon
mov a,mon
cjne a,#13d ,clock_end
mov mon,#01d
inc year
mov a,year
cjne a,#100d ,clock_end
mov year,#00d
clock_end:
call fl_out
ret
mou_12:
db 31d, 28d, 31d, 30d, 31d,30d
db 31d, 31d, 30d,31d, 30d,31d
year_d:
db 29d, 28d, 28d, 28d, 29d, 28d , 28d, 28d, 29d, 28d
db 28d, 28d, 29d, 28d, 28d, 28d , 29d, 28d, 28d, 28d
db 29d, 28d, 28d, 28d, 29d, 28d , 28d, 28d, 29d, 28d
db 28d, 28d, 29d, 28d, 28d, 28d , 29d, 28d, 28d, 28d
db li jie 2000.5.15
;***************************************
t1:
push a
push psw
push b
clr fl_ms_f
djnz t_1s ,t1_end
clr fl_s_f
inc sec
call adj_w
;********************************
t1_end:
pop b
pop psw
pop a
reti
adj_w:
clr tr1
mov a,#T_L_100ms
add a, w_adj ;*******have 5 order
mov tl1 ,a
mov a,#T_H_100ms
addc a, #00h
mov th1,a
mov t_1s,#timer_no
setb tr1
ret
fl_out:
jb fl_ms_f ,fl_out_end
setb fl_ms_f
mov a,t_1s
mov b,#02d
div ab
mov a,b
jnz to_d1
cpl fl_250ms
to_d1:
mov a,t_1s
mov b,#04d
div ab
mov a,b
jnz to_d2
cpl fl_500ms
to_d2:
fl_out_end:
call sec_out
ret
sec_out:
jb fl_s_f ,sec_out_end
setb fl_s_f
mov a,sec
mov b,#07d
jnb fl_3s,za1
mov b,#02d
za1:
div ab
mov a,b
jnz sec_out_end
cpl fl_3s
sec_out_end:
ret
;**********************************
key_del:
mov a,key_data
jnz kl_12
mov a,frist
jnz kl_13
ret
kl_13:
mov key_data,frist
mov frist,#0
clr key_over
jmp sf_beep
kl_12:
jnb key_over,kl11
mov a,t_30ms
add a,#03
mov b,#60d
div ab
mov a,sec
cjne a,b,key_del_end
clr key_over
jmp set_key
kl11:
mov t_30ms,sec
setb key_over
key_del_end:
call sf_a
cjne a,#key_da,sfg_12
clr key_over
jmp sf_beep
sfg_12:
mov frist,key_data
mov key_data,#0
ret
;****************************************
key_bord:
acall re_k
mov a,key_data
jz key_bord1_end
;acall psf_key0
key_bord1_end:
setb key_f
ret
set_key:
mov a,key_data
cjne a,#01h,set_cc1
setb set_al4_f
sjmp sf23
set_cc1:
cjne a,#02h,sf23
setb set_clk_f
sf23:
ret
;************************************
sf_key:
call clock
call week_auto
call al_out
setb key_f
call led
call sf_a
cjne a,#key_da,sf_key
call sf_beep
ret
sf_beep:
clr beep_f
call timer_20ms
setb beep_f
ret
;********************************
re_k:
mov key_data,#00h
mov p1,#00h
mov a,p3
orl a,#01111111b
mov p3,a
clr key_f
mov a,p3
setb key_f
mov p1,#0ffh
anl a ,#00000110b
cjne a,#00000110b,you_key
re_k_end:
ret
you_key:
call timer_20ms
;call led
mov p1,#00h
mov a,p3
orl a,#01111111b
mov p3,a
clr key_f
mov a,p3
setb key_f
mov p1,#0ffh
anl a ,#key_da
cjne a,#key_da,you_key1
ret;sjmp re_k_end
you_key1:
jb acc.1,key_kb
mov key_data,#02h
key_kb:
jb acc.2,sf_key0
mov key_data,#01h
sf_key0:
ret
sf_a:
mov p1,#00h
mov a,p3
orl a,#01111111b
mov p3,a
clr key_f
mov a,p3
setb key_f
anl a ,#key_da
ret
al_asc:
db 06d,40d, 06d,50d, 07d,00d, 07d,10d;am 4_al
db 07d,15d, 013d,40d, 13d,45d, 14d,15d;pm 4_al