中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 單片機中斷舉例

        單片機中斷舉例

        作者: 時間:2016-11-26 來源:網(wǎng)絡 收藏

        單片機中斷舉例


        本文引用地址:http://www.antipu.com.cn/article/201611/321780.htm

        單片機多任務執(zhí)行。P1口LED燈閃爍、P3口按鍵輸入,兩任務“同時”執(zhí)行。

        方案一:在主程序中循環(huán)調(diào)用P1口LED燈閃爍子程序,P3口按鍵掃描子程序;

        缺點:可能造成P3口按鍵輸入不靈的現(xiàn)象;

        方案二:主程序一直循環(huán)調(diào)用P1口LED燈閃爍子程序,P3口按鍵程序采用中斷執(zhí)行。

        以下程序將兩個外部中斷全部打開,同學們可以在proteus中驗證。

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

        //51單片機中斷嵌套程序演示

        //作者:曾憲陽

        //網(wǎng)址:http://hi.baidu.com/zxymcu

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

        #include

        #include

        #defineucharunsignedchar

        #defineuintunsignedint

        voiddelay_ms(uintt)

        {

        ucharx,y;

        for(t;t>0;t--)

        {

        for(x=0;x<114;x++)

        for(y=0;y<1;y++);

        }

        }

        voidLED(void)

        {

        ucharx;

        P1=0XFE;

        for(x=0;x<8;x++)

        {

        delay_ms(500);

        P1=_crol_(P1,1);

        }

        }

        voidLED_0(void)interrupt0using1

        {

        ucharx;

        P0=0XFE;

        for(x=0;x<8;x++)

        {

        delay_ms(500);

        P0=_crol_(P0,1);

        }

        }

        voidLED_1(void)interrupt2using2

        {

        ucharx;

        P2=0XFE;

        for(x=0;x<8;x++)

        {

        delay_ms(500);

        P2=_crol_(P2,1);

        }

        }

        voidmain(void)

        {

        EA=1;EX0=1;EX1=1;

        IT0=1;IT1=1;

        while(1)

        {

        LED();

        }

        }




        關鍵詞: 單片機中斷舉

        評論


        技術專區(qū)

        關閉