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

当前位置:首页 > 单片机技术文章 > 51单片机 > 详细内容
多功能AT89C2051倒计时器
发布时间:2009/7/7  阅读次数:6992  字体大小: 【】 【】【

;*******************************min to led
MOV B,#10D
DIV AB
mov led2,a
mov a,b
mov led1,a
;*******************************hour to led
mov a,r7
MOV B,#10D
DIV AB
mov r1,a
mov a,b
mov b,r1
mov r1,a

jnz tt_2

tt_1: mov a,#led_blk
tt_2:
mov led3,a
clr all_s

mov a,b
jz tt_3
setb all_s
mov led3 ,r1
tt_3:
ret


;********************
; LED_PROGRAM
;*******************

LED:

mov c,flash_f
jnc ffl_1
mov c,timer_50ms
jc ffl_1

;mov led1,#led_blk
;mov led2,#led_blk
;mov led3,#led_blk
ajmp led_end

ffl_1:


mov dptr,#led_asc
;***************************led1
mov a,led1
movc a,@a+dptr
mov c, timer_50ms
mov acc.0,c

mov p1,a

clr led_1

acall timer_1ms

setb led_1
;*************************led2
led_led2:

mov a,led2
movc a,@a+dptr
mov p1,a

clr led_2
acall timer_1ms
setb led_2
;*************************led3
led_led3:
mov a,led3
movc a,@a+dptr
mov c,all_s
mov acc.0 ,c


mov p1,a

clr led_3
acall timer_1ms
setb led_3
;*************************
led_end:
mov p1,#0ffh
mov a,p3
orl a,#11111000b
mov p3,a

ret

led_asc:
db 11101110B;0 "bafgecdh"
db 10000100B;1
db 11011010B;2
db 11010110B;3
db 10110100B;4
db 01110110B;5
db 01111110B;6
db 11000100B;7
db 11111110B;8
db 11110110B;9
DB 00000000B;BLACK=>0aH
DB 01111000B;f=>b
dB 11101100B;e=>C
DB 00110000B;1,=>D

;**********************************
;delay
;********************************

timer_1ms:
push b
mov r2,#01h
a_1: mov b,#020h
b_1: djnz b,b_1
djnz r2,a_1
pop b
ret

;******************
; TO-T1_INT T1定时器完成100毫秒定时(6M晶振)
;******************

T1:
setb tr0
PUSH ACC ;程序参数保护
PUSH b ;
push psw

inc time_led1
mov a,time_led1
cjne a,#5d,t1_n1;判断time_led1中是否满5?
mov time_led1,#00h
cpl timer_50ms;满50毫秒后对50毫秒标志位取反

; mov a,timers
; cjne a,#10d ,t1_n11;判断timers中是否满10?
;t1_n12:
; clr timer_1s;满1秒后对1秒标志位取反

sjmp t1_n1
;*********************************
t1_end_2: ajmp t1_end_1
;********************************

;t1_n11: jc t1_n12
; setb timer_1s

t1_n1: djnz timers ,t1_end_2
mov timers,#tis

inc time_led3
mov a,time_led3
cjne a,#03d,t1_sec
mov time_led3,#00h
cpl timer_3s
t1_sec:
inc sec
mov a,sec
cjne a,#60d ,t1_end
mov sec,#00d

jnb al1_f ,t1_al1

mov a,al1_min_t
mov b,al1_hour_t
mov c ,aal1_f
acall al_all
mov al1_min_t,a
mov al1_hour_t,b
mov aal1_f,c

t1_al1:
jnb al2_f ,t1_al2
mov a,al2_min_t
mov b,al2_hour_t
mov c ,aal2_f
acall al_all
mov al2_min_t,a
mov al2_hour_t,b
mov aal2_f,c

t1_al2:
jnb al3_f ,t1_al3
mov a,al3_min_t
mov b,al3_hour_t
mov c ,aal3_f
acall al_all
mov al3_min_t,a
mov al3_hour_t,b
mov aal3_f,c

t1_al3:
T1_END:
t1_end_1:
;************************************ sub t0 timer
clr c
clr tr0
mov b,timer_no
mov a,#til
add a,tl0

addc a,b ;*******have 5 order
mov tl1 ,a

mov a,#tih
addc a, th0
mov th1,a
mov th0,#00h
mov tl0,#00h
setb tr1
pop psw
pop b ;
pop acc ;
RETI ;

;************************************
beep:
clr ha

mov r6,#060h
bee_2: mov r4,#0ffh
bee_1:
djnz r4 ,bee_1
djnz r6,bee_2
setb ha
ret
;***************************************
stop:
mov a,#0ffh
mov p1,a
mov p3,a

mov a,pcon
orl a,#00000010b
mov pcon,a
ret

al_out_way:


jnb aal1_f ,al_out1

mov r3,#0ffh
pnp_3:
mov b,#060h

pnp_4:
push b

acall led_jmp_1;led_times

mov c,timer_50ms
mov ha ,c
pop b
djnz b ,pnp_4
djnz r3 ,pnp_3

mov c,al2_f
orl c,al3_f
jc al_out54
acall stop

al_out54:
clr aal1_f
clr al1_f
sjmp al_out4

al_out1:
jnb aal2_f ,al_out2


clr pnp1
mov r3,#0ffh
pnp_1:
mov b,#020h

pnp_2:
push b

acall led_jmp_1;led_times
pop b
djnz b ,pnp_2
djnz r3 ,pnp_1

setb pnp1

mov c,al1_f
orl c,al3_f
jc al_out64
acall stop

al_out64:
clr aal2_f
clr al2_f
sjmp al_out4


al_out2:
jnb aal3_f ,al_out3
clr pnp2

al_out3:
jnb turn_f ,al_out4
acall stop
al_out4:
ret
;*******************************************
al_all:
jc al_all_1
dec a
jnz al_all_1
mov a,b
jz al_all_3
dec b
sjmp al_all_2

al_all_3:
setb c
sjmp al_all_1

al_all_2:
mov a,#60d
al_all_1:

ret

  

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

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

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