1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 1850|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

單片機(jī)定時(shí)計(jì)數(shù)器使用

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code num[]={
0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
uint t=0,x,x1,x2,x3,y;
void delay(uint a)
{
        uchar j;
        while(--a)
        {
                for(j=0;j<120;j++)
                ;
        }
}
void inint_0()
{
        TMOD=0x51;
        TH0=0x3c;
        TL0=0xb0;
        TH1=0x00;
        TL1=0x00;
        IE=0x82;
}
void display(uint c)
{
        P2=0xfe;
        P1=num[c/1000];
        delay(5);
        P2=0xfd;
        P1=num[(c/100)%10];
        delay(5);
        P2=0xfb;
        P1=num[(c/10)%10];
        delay(5);
        P2=0xf7;
        P1=num[c%10];
        delay(5);
}
yunsuan()
{
        x3=x2*256;
        x=x1+x3;
        return x;
}
void main()
{
        inint_0();
        TR0=1;
        TR1=1;
        while(1)
        {
                y=yunsuan();
                display(y);
        }
}
void timer0_server() interrupt 1
{
        TR0=0;
        TR1=0;
        TH0=0x3c;
        TL0=0xb0;
        t++;
        if(t==20)
        {
                t=0;
                x2=TH1;
                x1=TL1;
                TH1=0x00;
                TL1=0x00;
        }
        TR0=1;
        TR1=1;
}

捕獲.PNG (15.42 KB, 下載次數(shù): 33)

捕獲.PNG
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表