在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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) > 設計應用 > 51單片機外部中斷程序

            51單片機外部中斷程序

            作者: 時間:2016-11-18 來源:網(wǎng)絡 收藏
            /*以下是能在keilC 中變異的源碼,直接粘貼過去就行,外部中斷0(INT0)和外部中斷1都有(INT1)*/

            /*程序很簡單,但是對新手來說還是很實用的*/

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

            /*******************************************************************/
            /* */
            /* 單片機開發(fā)系統(tǒng)演示程序 - INT0 INT1 中斷計數(shù) */
            /* */
            /* 6位數(shù)碼管顯示 */
            /* */
            /* */
            /*******************************************************************/

            #include < reg51.h >
            #include

            #define uchar unsigned char
            #define uint unsigned int

            unsigned char code LEDData[ ] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,
            0x82,0xF8,0x80,0x90,0xff};

            unsigned char data display[8] = {0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00};

            unsigned char code scan_bit[8] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};

            unsigned char count0,count1,temp=0 ;

            /********************************************************
            * *
            * 延時函數(shù) *
            * *
            ********************************************************/
            void delay(uint ms)
            // 延時子程序
            {
            uchar k;
            while(ms--)
            {
            for(k = 0; k < 100; k++);
            }
            }

            /********************************************************
            * *
            * 數(shù)據(jù)處理與顯示函數(shù) *
            * *
            ********************************************************/
            void disp_count()
            {
            char n;

            temp=count0;

            display[2]=temp/100; //數(shù)據(jù)處理
            temp=temp%100;
            display[1]=temp/10;
            display[0]=temp%10;

            if(display[2]==0) //高位為0,不顯示
            {
            display[2]=0x0a;
            if(display[1]==0)
            display[1]=0x0a;
            }

            temp=count1;

            display[7]=temp/100; //數(shù)據(jù)處理
            temp=temp%100;
            display[6]=temp/10;
            display[5]=temp%10;

            if(display[7]==0) //高位為0,不顯示
            {
            display[7]=0x0a;
            if(display[6]==0)
            display[6]=0x0a;
            }

            for(n=0;n<8;n++)
            {
            P0 =LEDData[display[n]] ; //顯示段碼
            P2 =scan_bit[n]; //輸出位碼
            delay(1);
            P2 = 0xff; //關閉顯示
            }
            }

            /********************************************************
            * *
            * 主程序 *
            * *
            ********************************************************/
            void main(void)
            {
            P0=0xff;
            P1=0xff;
            P2=0xff;

            IT0=0; //低電平觸發(fā)
            // IT0=1; //下降沿觸發(fā)
            IT1=0; //低電平觸發(fā)
            // IT1=1; //下降沿觸發(fā)
            PX0=1;
            EA=1;
            EX1=1;
            EX0=1;

            while(1)
            {
            disp_count();
            }
            }

            /********************************************************
            * *
            * INT0中斷函數(shù) *
            * *
            ********************************************************/
            void counter0(void) interrupt 0
            {
            uchar x;
            EX0=0;
            count0++;

            for(x=0;x<10;x++)
            {
            disp_count();
            }
            EX0=1;
            }

            /********************************************************
            * *
            * INT1中斷函數(shù) *
            * *
            ********************************************************/
            void counter1(void) interrupt 2
            {
            uchar x;
            EX1=0;
            count1++;

            for(x=0;x<10;x++)
            {
            disp_count();
            }
            EX1=1;
            }

            /********************************************************/



            關鍵詞: 51單片機外部中

            評論


            技術專區(qū)

            關閉