数码管程序——跪求一个不用锁存器

2019-07-16 02:57发布

跪求一个不用锁存器,但是可以让数码管从000跳动到999的范例程序,洒家怎么都想不通,跪求啊~我可以写出带锁存器的可是写不出不带锁存器的程序,求各位帮帮忙啊~
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
19条回答
哭呢还是笑
2019-07-18 09:00
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code duma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar code wema[]={0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7};
uint i,j;

uchar num,bai,shi,ge;
int shu;

void delayms(int xms)
{
    uint x,y;
        for(x=xms;x>0;x--)
         for(y=110;y>0;y--);
}

void sc(char bai,char shi,char ge)
{
            P2=duma[bai];
                        P1=0xf0;
                        delayms(3);
                        P2=duma[shi];
                        P1=0xf1;
                        delayms(1);
                        P2=duma[ge];
                        P1=0xf2;
                        delayms(1);
                        }

void init_time1(void)
{
    shu=0;
    TMOD=0x10;          //使用模式1,16位定时器,使用"|"符号可以在使用多个定时器时不受影响                     
    TH1=(65536-45872)/256;                  //重新赋值
        TL1=(65536-45872)%256;
        EA=1;             //总中断打开
        ET1=1;            //定时器T1允许中断
        TR1=1;            //定时器T1开始工作
}          

void time1() interrupt 3
{
        TH1=(65536-45872)/256;          //重新赋值
        TL1=(65536-45872)/256;
    num++;
}

void main()
{  
   init_time1();
        while(1)
        {
           if(num==1)
           {
                           num=0;
                        shu++;
                        if(shu==999)
                        {
                           shu=0;
                        }
                 }
                     bai=shu/100;
                        shi=shu%100/10;
                        ge=shu%10;
                        sc(bai,shi,ge);
                   }
}

一周热门 更多>