在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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>

            新聞中心

            LPC1114外中斷應(yīng)用

            作者: 時(shí)間:2016-11-10 來(lái)源:網(wǎng)絡(luò) 收藏
            LPC1114微處理器每一個(gè)GPIO都可以中斷,不過(guò)在設(shè)計(jì)中斷時(shí)需要注意,下面就舉例說(shuō)明:

            /**************************************************************************************
            * global variable
            **************************************************************************************/
            volatile uint8 KeyValue = 0;

            /**************************************************************************************
            * FunctionName : KeyInit()
            * Description : 初始化按鍵
            * EntryParameter : None
            * ReturnValue : None
            **************************************************************************************/
            void KeyInit(void)
            {
            // 設(shè)置為輸入端口
            GPIOSetDir(PORT1, KEY1, 0);
            GPIOSetDir(PORT1, KEY2, 0);
            GPIOSetDir(PORT1, KEY3, 0);
            GPIOSetDir(PORT1, KEY4, 0);
            GPIOSetDir(PORT1, KEY5, 0);
            GPIOSetDir(PORT1, KEY6, 0);

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

            // 設(shè)置為低電平中斷
            GPIOSetInterrupt(PORT1, KEY1, 1, 0, 0);
            GPIOSetInterrupt(PORT1, KEY2, 1, 0, 0);
            GPIOSetInterrupt(PORT1, KEY3, 1, 0, 0);
            GPIOSetInterrupt(PORT1, KEY4, 1, 0, 0);
            GPIOSetInterrupt(PORT1, KEY5, 1, 0, 0);
            GPIOSetInterrupt(PORT1, KEY6, 1, 0, 0);

            // 使能中斷
            GPIOIntEnable(PORT1, KEY1);
            GPIOIntEnable(PORT1, KEY2);
            GPIOIntEnable(PORT1, KEY3);
            GPIOIntEnable(PORT1, KEY4);
            GPIOIntEnable(PORT1, KEY5);
            GPIOIntEnable(PORT1, KEY6);

            NVIC_EnableIRQ(EINT1_IRQn); // 使能PORT1中斷
            }

            /**************************************************************************************
            * FunctionName : PIOINT1_IRQHandler()
            * Description : 中斷服務(wù)函數(shù)
            * EntryParameter : None
            * ReturnValue : None
            **************************************************************************************/
            void PIOINT1_IRQHandler(void)
            {
            uint32 key;

            key = GPIOIntStatus(PORT1, KEY1);
            if (key == 1)
            {
            KeyValue = K1;
            GPIOIntClear(PORT1, KEY1);
            return ;
            }

            key = GPIOIntStatus(PORT1, KEY2);
            if (key == 1)
            {
            KeyValue = K2;
            GPIOIntClear(PORT1, KEY2);
            return ;
            }

            key = GPIOIntStatus(PORT1, KEY3);
            if (key == 1)
            {
            KeyValue = K3;
            GPIOIntClear(PORT1, KEY3);
            return ;
            }

            key = GPIOIntStatus(PORT1, KEY4);
            if (key == 1)
            {
            KeyValue = K4;
            GPIOIntClear(PORT1, KEY4);
            return ;
            }

            key = GPIOIntStatus(PORT1, KEY5);
            if (key == 1)
            {
            KeyValue = K5;
            GPIOIntClear(PORT1, KEY5);
            return ;
            }

            key = GPIOIntStatus(PORT1, KEY6);
            if (key == 1)
            {
            KeyValue = K6;
            GPIOIntClear(PORT1, KEY6);
            return ;
            }
            }

            /**************************************************************************************
            * End Of File
            **************************************************************************************/

            在中斷函數(shù)中需要注意的是,如果直接使用如下格式,將無(wú)法讀取端口中斷狀態(tài)。

            if (GPIOIntStatus(PORT1, KEY6) == 1)
            {
            KeyValue = K6;
            GPIOIntClear(PORT1, KEY6);
            return ;
            }



            需要先定義一個(gè)臨時(shí)變量,讀取端口狀態(tài),再通過(guò)變量值進(jìn)行判斷,此問(wèn)題已經(jīng)記過(guò)驗(yàn)證。



            關(guān)鍵詞: LPC1114外中

            評(píng)論


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

            關(guān)閉