<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > LPC1114_外部中斷程序_MDK編譯環(huán)境

          LPC1114_外部中斷程序_MDK編譯環(huán)境

          作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
          main.c
          #include "LPC11XX.h"
          #include "gpio.h"
          #include "timer16.h"
          #include "main.h"
          #include "Key.h"
          #include "LCD.h"
          void Delay_Sec(unsigned char Time) //1s*Time延時(shí)函數(shù)
          {
          u16 i;
          while(Time)
          {
          for(i=0;i<3000000;i++);
          Time--;
          }
          }
          void Delay_Ms(unsigned int Time) //1Ms*Time延時(shí)函數(shù)
          {
          u16 i;
          while(Time)
          {
          for(i=0;i<3000;i++);
          Time--;
          }
          }
          void Delay_Us(unsigned int Time) //1Us*Time延時(shí)函數(shù)
          {
          u8 i;
          while(Time)
          {
          for(i=0;i<3;i++);
          Time--;
          }
          }
          int main(void)
          {
          //SystemInit(); //系統(tǒng)初始化--主要是設(shè)置主時(shí)鐘
          //GPIOInit(); //IO口初始化--主要是開(kāi)啟GPIO時(shí)鐘
          //GPIOSetDir( 0, 3, 1 ); //設(shè)置P0.3為輸出(LPC1114單片機(jī),輸出需設(shè)置為1,輸入需設(shè)置為0)
          LPC_GPIO0->DIR |= (0x1<<3); //設(shè)置P0.3為輸出
          LPC_GPIO2->DIR |= (0x1<<9);
          Key_GPIO_Init();
          Key_Intrrupt_Init();
          while(1)
          {
          //GPIOSetValue( 0, 3, 0 ); //給P0.3位寫(xiě)0
          //LPC_GPIO0->DATA &= ~(0x1<<3); //給P0.3位寫(xiě)0
          LCD_RW_High;
          //for(i=0;i<0xFFFFF;i++); //延時(shí)
          Delay_Ms(100); //延時(shí)
          //GPIOSetValue( 0, 3, 1 ); //給P0.3位寫(xiě)1
          //LPC_GPIO0->DATA |= (0x1<<3); //給P0.3位寫(xiě)1
          LCD_RW_Low;
          //for(i=0;i<0xFFFFF;i++); //延時(shí)
          Delay_Ms(100); //延時(shí)
          }
          }
          key.c
          #include "LPC11XX.h"
          #include "gpio.h"
          #include "main.h"
          #include "Key.h"
          void Key_GPIO_Init(void)
          {
          LPC_GPIO1->DIR &= ~(0x1<<8); //設(shè)置P1.8為輸入
          }
          void Key_Intrrupt_Init(void)
          {
          /*********配置中斷*********/
          GPIOSetInterrupt(1,8,1,0,0); //P1.8低電平觸發(fā)中斷
          /*********使能中斷*********/
          GPIOIntEnable(1,8);
          /*********使能中斷入口*********/
          NVIC_EnableIRQ(EINT1_IRQn);
          }
          gpio.c
          #include "LPC11xx.h" /* LPC11xx Peripheral Registers */
          #include "gpio.h"
          void PIOINT1_IRQHandler(void)
          {
          uint32_t regVal;
          gpio1_counter++;
          regVal = GPIOIntStatus( 1, 8 );
          if ( regVal )
          {
          LPC_GPIO0->MASKED_ACCESS[(1<<3)] = (0<<3);
          Delay_Ms(2000);
          LPC_GPIO0->MASKED_ACCESS[(1<<3)] = (1<<3);
          Delay_Ms(2000);
          LPC_GPIO0->MASKED_ACCESS[(1<<3)] = (0<<3);
          Delay_Ms(2000);
          LPC_GPIO0->MASKED_ACCESS[(1<<3)] = (1<<3);
          Delay_Ms(2000);
          //GPIOSetValue( 0, 3, 0 ); //給P0.3位寫(xiě)0
          //Delay_Ms(1000);
          //GPIOSetValue( 0, 3, 1 ); //給P0.3位寫(xiě)0
          //Delay_Ms(1000);
          GPIOIntClear( 1, 8 );
          }
          return;
          }


          評(píng)論


          技術(shù)專(zhuān)區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();