| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 906 人关注过本帖
标题:自己变得一个51汇编倒计时程序,
取消只看楼主 加入收藏
白色层次
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-11-1
收藏
 问题点数:0 回复次数:1 
自己变得一个51汇编倒计时程序,
自己写的一个51单片机 汇编倒计数程序,从 15分47秒,开始到计时。可是数码管,不能正常显示,个位大大帮小弟看看吧。谢谢了

                                DISBUF0    EQU    30H
                DISBUF1    EQU    31H
                DISBUF2    EQU    32H
                DISBUF3    EQU    33H   
                TIME_S    EQU    40H
                TIME_N    EQU    41H
               
                ORG        0000H
                AJMP    MAIN
                ORG        000BH
                AJMP    T0_SR
                MAIN:
                    CALL    T0init
                    MOV        R2,#0
                    MOV        R3,#0
                    MOV        30H,#1
                    MOV        31H,#5
                    MOV        32H,#4
                    MOV        33H,#7
                L2:    CALL    DISP
                    JMP        L2   
                T0init:
                    MOV        TMOD,    #01H
                    MOV        TH0,#HIGH(-10000)
                    MOV        TL0,#LOW(-10000)
                    SETB    ET0
                    SETB    EA
                    SETB    TR0
                    RET
                T0_SR:
                    PUSH    PSW
                    PUSH    ACC
                    INC        R2
                    
                    CJNE    R2,#100,ENDOK
                    MOV        R2,#0
                    MOV        TIME_N,#15
                    MOV        TIME_S,#47
                    DEC        TIME_S
                    
                    MOV        A,TIME_S
                                        CJNE    A,#0,L1
                    MOV        TIME_S,#59
                    DEC        TIME_N
                    MOV        A,TIME_N
                    CJNE    A,#0,L1
                    MOV        TIME_N,#59
               
                L1:    CALL     H2BCD
            ENDOK:    CLR        TR0
                    MOV        TH0,#high(-10000)
                    MOV        TL0,#low(-10000)
                    SETB    TR0
                    POP        ACC
                    POP        PSW
                    RETI
            H2BCD:               
                    MOV     A, TIME_S
                    MOV        B,#10
                    DIV        AB
                    MOV        33H,A
                    MOV        32H,B
                    MOV        A,TIME_N
                    MOV        B,#10
                    DIV        AB
                    MOV        31H,A
                    MOV        30H,B
                    RET        
 
            DISP:
                    MOV     R0,#30H
                    MOV     R4,#4
                    MOV     R1,#0FEH

            LOOP:    MOV     A,@R0
                    MOV     DPTR,#DISCODE
                    MOVC    A,@A+DPTR
                    MOV     P0,A
                    MOV        P1,R1
                    CALL    DELAY
                    MOV     P1,#0FFH
                    INC     R0
                    MOV     A,R1
                    RL      A
                    MOV     R1,A
                     DJNZ    R4,LOOP
                    RET

        DELAY:    MOV    R6,#4H
    DE1:    MOV    R5,#150
    DE2:    MOV    R4,#150
        DJNZ    R4,$
        DJNZ    R5,DE2
        DJNZ    R6,DE1
        RET


   
                    RET
DISCODE:      DB         0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71
      

                END
搜索更多相关主题的帖子: 单片机 数码管 
2011-11-09 11:59
白色层次
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-11-1
收藏
得分:0 
meira
2011-11-11 19:37
快速回复:自己变得一个51汇编倒计时程序,
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023053 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved