电子制作天地网站欢迎您的光临,欢迎提出宝贵意见或建议。本站信息产业部备案: 粤ICP备05114582号
采用AT89C2051的智能时钟
AT90C2051 DIGITAL CLOCK

时间:2008-1-17 22:39:21 来源:网络 作者:未知 编辑: 【关闭


采用AT89C2051的智能时钟,AT90C2051 DIGITAL CLOCK

关键字:AT89C2051的智能时钟制作


led_out1:
mov led2,#00h
mov led3,#u_led
mov led4,#t_led
mov led5,#blk_led
mov led1,#blk_led
ret
;********************************
led_al:
mov a,k1_data
cjne a,#017d,lo1
acall beep_timer
sjmp led_al_end
lo1:
cjne a,#18d,ld1
acall led_out1
sjmp led_al_end
ld1:
inc a
mov b,#02d
div ab
;**********
mov led1,a
;**********
dec a
rl a
mov r0,#al1_h
add a,r0
mov r0,a
mov a,@r0
acall bcd_8
mov led2,a
jnz ld2
mov led2,#blk_led
ld2:
mov a,b
add a,#10d
mov led3,a
;************************************
inc r0
mov a,@r0
acall bcd_8
add a,#10d
mov led4,a
mov led5,b

;***************************flash bit
jb fl_250ms,led_al_end
acall jj_bit
jnz led_al_e
mov led4,#blk_led
mov led5,#blk_led
sjmp led_al_end
led_al_e:
mov led2,#blk_led
mov led3,#blk_led
led_al_end:
acall led
ret
;***************************************
proc set_clock
set_clock:
mov k1_data,#01d
mov k2_data,#01d
clr set_over
call led_cl
call key_bord
call sf_key
mov key_data,#0
mov frist,#0
set_al41:
call clock
acall week_auto
call al_out
acall led_cl
acall key_bord
call key_del
acall key_cl
jnb set_over,set_al41
;acall key_bord
clr a
mov k1_data,a
mov k2_data,a
mov key_data,a
mov frist,a
ret
end
;**************************************
proc key_cl
key_cl:
mov a,key_data
jz key_al_end
cjne a,#01d,k2_al

inc k1_data ;(1-8)
mov a,k1_data
cjne a,#9d,key_al_end
mov k1_data,#01d
sjmp key_al_end
k2_al:
mov a,k1_data
cjne a,#08d,ke2
setb set_over
sjmp key_al_end
ke2:
dec a
mov dptr,#asc_h
movc a,@a+dptr
mov b,a
;********************************
mov r0,#sec
mov a,k1_data
dec a
add a,r0
mov r0,a
inc @r0
mov a,@r0
div ab
mov a,b
mov @r0,a
key_al_end:
ret
end
asc_h:
db 60d,60d,24d,32d,13d,100d,100d

proc led_cl
led_cl:
mov dptr,#led_ord_3
mov a,k1_data
dec a
mov b,#02h
mul ab
jmp @a+dptr
led_ord_3: ajmp led_k0_2
ajmp led_k1_2
ajmp led_k2_2
ajmp led_k3_2
ajmp led_k4_2
ajmp led_k5_2
ajmp led_k6_2
ajmp led_k7_2

led_k0_2: ; led sec
mov led2,#blk_led
mov led3,#dot_led
mov a,sec
acall bcd_8
add a,#10d
mov led4,a
mov led5,b
jb fl_250ms ,lk1
mov led4,#blk_led
mov led5,#blk_led
lk1:
ajmp led_jmp_5_end
led_k1_2: ; led min,hour
acall led_hour
jb fl_250ms ,lk2
mov led4,#blk_led
mov led5,#blk_led
lk2:
ajmp led_jmp_5_end
led_k2_2: ;led min,hour
acall led_hour
jb fl_250ms ,lk3
mov led2,#blk_led
mov led3,#blk_led
lk3:
ajmp led_jmp_5_end
led_k3_2: ;led day,mon
acall led_mon
jb fl_250ms ,lk4
mov led4,#blk_led
mov led5,#blk_led
lk4:
ajmp led_jmp_5_end
led_k4_2: ; led day,mon
acall led_mon
jb fl_250ms ,lk5
mov led2,#blk_led
mov led3,#blk_led
lk5:
ajmp led_jmp_5_end
led_k5_2: ; led year
mov led2,#2d
mov led3,#0d
mov a,year
acall bcd_8
mov led4,a
mov led5,b
jb fl_250ms ,lk6
mov led4,#blk_led
mov led5,#blk_led
lk6:
ajmp led_jmp_5_end
led_k6_2: ;led w_adj
mov led2,#d_led
mov led3,#blk_led
mov a,w_adj
acall bcd_8
mov led4,a
mov led5,b
jb fl_250ms ,lk7
mov led4,#blk_led
mov led5,#blk_led
lk7:
ajmp led_jmp_5_end
led_k7_2: ;led out
acall led_out1
led_jmp_5_end:
mov led1,week
acall led
ret
end

led_hour:
mov a,hour
acall bcd_8
mov led2,a
jnz lj1
mov led2,#blk_led
lj1:
mov a,b
add a,#10d
mov led3,a
;*********************
mov a,min
acall bcd_8
add a,#10d
mov led4,a
mov led5,b
ret
led_mon:
mov a,mon
jnz lj5
inc mon
mov a,mon
lj5:
acall bcd_8
mov led2,a
jnz lj2
mov led2,#blk_led
lj2:
mov led3,b
;*********************
mov a,day
jnz lj4
inc day
mov a,day
lj4:
acall bcd_8
mov led4,a
jnz lj3
mov led4,#blk_led
lj3:
mov led5,b
ret
;********************************************
al_out:
jb ha_over,al_out_end
mov r7,#8d
mov r1,#al8_m
al_ch_1:
mov r0,#min
mov r6,#02d ;min hour
al_l:
mov a,@r0
mov b,@r1
cjne a,b ,al_ch
inc r0
dec r1
djnz r6 ,al_l
;**************************************************
mov a,r7
dec a
mov r0,#al1
add a,r0
mov r0,a
mov a,@r0
mov c,acc.0
cpl c
anl c,fl_250ms
cpl c
mov beep_f,c
acall beep_out
al_ch:
clr c
mov a,r1
subb a,r6
mov r1,a
djnz r7,al_ch_1
al_out_end:
ret

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

这是上面程序汇编以后获得的编程器烧写文件:clock.rar


◆相关文章◆
◆ 编辑推荐 ◆
用户:
更多评论
您要为您所发的言论的后果负责,故请各位遵纪守法并注意语言文明。60个字以内
留言:
验证码:

免责声明:
●本站所有内容均来自网络,以学习为目的,如果侵犯了您的利益,请来信告知,立即删除,站长邮件为"diy+dzdiy.com",请将"+"变更为"@"
●电子制作存在风险,请注意人身安全,如果您在根据本站电路进行制作过程中发生伤害,本站不负任何责任。

版权所有:www.dzdiy.com ? 2001-2019 本站信息产业部备案: 粤ICP备05114582号