在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 數(shù)碼管計(jì)時(shí)器程序

            數(shù)碼管計(jì)時(shí)器程序

            作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
            這是一個(gè)51hei網(wǎng)友測(cè)試通過(guò)的計(jì)時(shí)器程序、電路很簡(jiǎn)單就不畫了數(shù)碼管的段選是P0口位選是P1口

            #include
            typedef unsigned char uint8;
            typedef unsigned int uint16;
            typedef unsignedlonguint32;
            code uint8 number[]={0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83, 0xa7,0xa1,0x86,0x8e}; //數(shù)字0到F
            uint16 counter = 0; //定義計(jì)數(shù)器初始化
            uint8 a[6]; //六個(gè)數(shù)碼管
            sbit ENLED = P1^4;
            sbit ADDR0 = P1^0;
            sbit ADDR1 = P1^1;
            sbit ADDR2 = P1^2;
            sbit ADDR3 = P1^3;
            void timer1_led()
            {
            TMOD |= 0x10; //寄存器狀態(tài)M0位置1,或運(yùn)算
            TMOD &= 0xDF;
            TH1 = 0xFC; //12*(65535-x)/11059200 =1s
            TL1 = 0x67;
            TR1 = 1; //定時(shí)器置1打開,計(jì)數(shù)器開始計(jì)時(shí)
            }
            void int_init()
            {
            ET1 = 1; // 打開定時(shí)器1溢出中斷使能置1
            EA = 1; //總閥門打開
            }
            refresh_led()
            {
            static uint8 j = 0; //靜態(tài)變量刷新
            switch(j)
            {
            case 0:ADDR0 = 0;ADDR1 = 0;ADDR2 = 0;j++;P0 = number[a[0]];break;
            case 1:ADDR0 = 1;ADDR1 = 0;ADDR2 = 0;j++;P0 = number[a[1]];break;
            case 2:ADDR0 = 0;ADDR1 = 1;ADDR2 = 0;j++;P0 = number[a[2]];break;
            case 3:ADDR0 = 1;ADDR1 = 1;ADDR2 = 0;j++;P0 = number[a[3]];break;
            case 4:ADDR0 = 0;ADDR1 = 0;ADDR2 = 1;j++;P0 = number[a[4]];break;
            case 5:ADDR0 = 1;ADDR1 = 0;ADDR2 = 1;j = 0;P0 = number[a[5]];break;
            default :break;
            }
            }
            main()
            {
            ENLED = 0;ADDR3 = 1; //138譯碼器使能
            timer1_led(); //定時(shí)初始化
            int_init();
            while(1);
            }
            void interrupt_timer1() interrupt 3 //中斷函數(shù)
            {
            static uint32 sec=0; //定義變量
            TH1 = 0xFC;
            TL1 = 0x67;
            counter++;
            if(1000==counter)
            {
            sec++;
            counter=0;
            a[0] = sec%10; //個(gè)位數(shù)取余
            a[1] = sec/10%10; //十位取余
            a[2] = sec/100%10; //百位取余
            a[3] = sec/1000%10; //...............
            a[4] = sec/10000%10;
            a[5] = sec/100000%10;
            }
            refresh_led();
            }

            本文引用地址:http://www.biyoush.com/article/201611/324040.htm


            評(píng)論


            技術(shù)專區(qū)

            關(guān)閉