51/AVR单片机技术驿站!  <在线翻译>     便利工具    特色网址   无弹窗、无插件的绿色站点...  英才招聘   学历查询  喜欢>>收藏我站 

当前位置:首页 > 单片机技术文章 > 51单片机 > 详细内容
采用AT89C2051的智能时钟
发布时间:2009/7/7  阅读次数:3948  字体大小: 【】 【】【

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

  

我要评论
  • 匿名发表
  • [添加到收藏夹]
  • 发表评论:(匿名发表无需登录,已登录用户可直接发表。) 登录状态:未登录
最新评论
所有评论[0]
    暂无已审核评论!

网站导航 管理登陆 ┊ 免责声明 问题反馈  友链说明
本站部分内容来自网络共享资源,如有冒犯您的权利请来信告之删除或纠正!
不得对本站进行复制、盗链或镜像,转载内容须获得同意或授权;欢迎友情链接、站务合作!

    我要报警 Alexa
 mcusy_cn#126.com (请把#改成@) 交流:522422171
本站学习交流群:138..158(高级群1-)、77930286(高级群2)、61804809(群3)
Copyright© MCUSY All Rights Reserved
本站网警备案号: WZ36040002485
  ICP备案证书号:粤ICP备09034963号