在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > STC89C52-秒表(精確10ms)同時(shí)LED二進(jìn)制計(jì)數(shù)

            STC89C52-秒表(精確10ms)同時(shí)LED二進(jìn)制計(jì)數(shù)

            作者: 時(shí)間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
            #include
            typedef unsigned char uint8;
            typedef unsigned int uint16;
            typedef unsignedlong uint32;
            /*數(shù)碼管0到F定義 */
            code uint8 number[] = {0xc0,0xf9,0xa4,0xb0,
            0x99,0x92,0x82,0xf8,
            0x80,0x90,0x88,0x83,
            0xa7,0xa1,0x86,0x8e};
            uint8 a[6];
            uint16 counter1 = 0;
            uint8 counter = 0;
            sbit ENLED = P1^4;
            sbit ADDR0 = P1^0;
            sbit ADDR1 = P1^1;
            sbit ADDR2 = P1^2;
            sbit ADDR3 = P1^3;
            /*定時(shí)器1初始化,并定時(shí)1ms*/
            void timer1_init()
            {
            TMOD |= 0x10;
            TMOD &= 0xdf;
            TH1 = 0xFC;
            TL1 = 0x67;
            TR1 = 1;
            }
            /*中斷初始化*/
            void int_init()
            {
            ET1 = 1;
            EA = 1;
            }
            /*刷新數(shù)碼管*/
            void refresh_led()
            {
            static uint8 j = 0;
            uint8 b = number[a[2]] - 0x80 ;

            switch(j)
            {
            case 0: ADDR0 = 0;ADDR1 = 0;ADDR2 = 0;P0 = number[a[0]];break;
            case 1: ADDR0 = 1;ADDR1 = 0;ADDR2 = 0;P0 = number[a[1]];break;
            case 2: ADDR0 = 0;ADDR1 = 1;ADDR2 = 0;P0 = b;break;
            case 3: ADDR0 = 1;ADDR1 = 1;ADDR2 = 0;P0 = number[a[3]];break;
            case 4: ADDR0 = 0;ADDR1 = 0;ADDR2 = 1;P0 = number[a[4]];break;
            case 5: ADDR0 = 1;ADDR1 = 0;ADDR2 = 1;P0 = number[a[5]];break;
            default: break;
            }
            if(7 == j++) j = 0;
            }
            main()
            {
            ENLED = 0; ADDR3 = 1;
            timer1_init();
            int_init();
            while(1);

            }
            /*中斷函數(shù)*/
            void interrupt_timer1() interrupt 3
            {
            static uint32 sec = 0;
            TH1 = 0xFC;
            TL1 = 0x66;
            counter++;
            if(counter == 10)
            {
            sec++;
            counter = 0;
            a[0] = sec%10;
            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;
            if(sec%100 == 0) counter1++; //LED時(shí)間1s
            if(counter1 == 256) counter1 = 0;
            }
            if(counter == 9)
            {ADDR0 = 0;ADDR1 = 1;ADDR2 = 1;P0 = ~counter1 ;}
            refresh_led();

            }


            評(píng)論


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

            關(guān)閉