乐源电子——让生活更加美好  http://www.leyuandz.com

                                                                              
设为首页
加入收藏
联系我们
首   页 网站简介 无线遥控 音频功放 单片机 DSP 网站产品 订货系统 邮购须知

                                                                             

循序渐进51study之实例9


;实例9
;简易时钟演示程序,开机显示: 12.00.00
                include sdo_h
;***显示缓冲区为30-37h***
time1s.come     bit   00h 
time.value      equ   40h 
times.value     equ   41h   ;秒存储器 
timem.value     equ   42h   ;分存储器
timeh.value     equ   43h   ;时存储器
;---------------------------------------- 
                org   0000h 
                ljmp  start

                org   000bh 
                push  acc
                push  dph
                push  dpl 
                mov   th0,#3ch ;重赋定时初值50ms
                mov   tl0,#0b0h
                djnz  time.value,exit>svct02
                mov   time.value,#20
                cpl   time1s.come
                cpl   comdir 
                mov   a,times.value 
                add   a,#1
                da    a
                mov   times.value,a 
                cjne  a,#60h,update>screen
                mov   times.value,#0 
                mov   a,timem.value 
                add   a,#1
                da    a
                mov   timem.value,a 
                cjne  a,#60h,update>screen
                mov   timem.value,#0 
                mov   a,timeh.value 
                add   a,#1
                da    a
                mov   timeh.value,a 
                cjne  a,#24h,update>screen
                mov   timeh.value,#0
update>screen:  lcall code_change 
exit>svct0:     pop   dpl
                pop   dph
                pop   acc
                reti
exit>svct02:    mov   a,time.value
                cjne  a,#10,exit>svct0
                cpl   time1s.come
                sjmp  update>screen

code_change:    mov   dptr,#dispcode
                mov   a,timeh.value
                swap  a
                anl   a,#0fh
                movc  a,@a+dptr
                mov   30h,a
                mov   a,timeh.value
                anl   a,#0fh
                movc  a,@a+dptr
                orl   a,#80h
                mov   31h,a
                mov   a,timem.value
                swap  a
                anl   a,#0fh
                movc  a,@a+dptr
                mov   32h,a
                mov   a,timem.value
                anl   a,#0fh
                movc  a,@a+dptr
                mov   33h,a
                mov   a,times.value
                swap  a
                anl   a,#0fh
                movc  a,@a+dptr
                mov   34h,a
                mov   a,times.value
                anl   a,#0fh
                movc  a,@a+dptr
                mov   35h,a
                jnb   time1s.come,no>doc
                mov   a,33h
                orl   a,#80h
                mov   33h,a
                ret
no>doc:         mov   a,33h
                anl   a,#7fh
                mov   33h,a
                ret
;--------------------------------------------------------- 
start:          mov   sp,#70h
                mov  tmod,#01
                mov   th0,#3ch
                mov   tl0,#0b0h
                mov   time.value,#20
                mov   timeh.value,#12h
                mov   timem.value,#0
                mov   times.value,#0
                setb  time1s.come
                lcall screen_clear<>
                setb  tr0
                setb  et0
                setb  ea

main:           lcall print10ms<>
                sjmp  main

dispcode:       db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,67h 
;----------------------------------------
                end

建议您使用IE 6.0或更高版本浏览器

乐源电子 版权所有
E-Mail:liang_2578@126.com
联系人:梁先生 电话:13601658256(若联系不上,请发短信留言)
QQ:569093346