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

          新聞中心

          LPC2131的GPIO輸出

          作者: 時(shí)間:2016-11-10 來(lái)源:網(wǎng)絡(luò) 收藏
          功能: 依次點(diǎn)亮板子上的八個(gè)LED,并循環(huán)顯示,每循環(huán)顯示一次,蜂鳴器蜂鳴一次。

          原理圖:

          本文引用地址:http://www.ex-cimer.com/article/201611/317410.htm

          程序清單:

          /****************************************Copyright (c)**************************************************
          *
          **--------------File Info-------------------------------------------------------------------------------
          ** File name:main.c
          ** Last modified Date: 2011-04-27
          ** Last Version:1.0
          ** Descriptions:The main() function example template
          **------------------------------------------------------------------------------------------------------
          ** Created by:lxliu
          ** Created date:2011-04-27
          ** Version:1.0
          ** Descriptions:The original version
          **------------------------------------------------------------------------------------------------------
          ** Modified by:
          ** Modified date:
          ** Version:
          ** Descriptions:
          **
          ********************************************************************************************************/
          #include "config.h"

          void DelayNS(uint32 dly)
          {
          uint32 i;

          for(;dly>0;dly--)
          for(i=0;i<50000;i++);
          }

          int main (void)
          {
          uint32 i; //循環(huán)變量
          uint32 LED = (1<<18); //P1[25:18]控制LED,初值指向LED1
          uint32 BEEP = (1<<7); //P0.7控制蜂鳴器,低電平蜂鳴器蜂鳴
          PINSEL2 = PINSEL2 & (~0x08); //P1[25:16]設(shè)置為GPIO功能
          PINSEL0 = 0x00000000; //P0[15:0]設(shè)置為GPIO功能
          IO0DIR = BEEP; //設(shè)置BEEP控制口為輸出
          IO0SET = BEEP; //蜂鳴器停止蜂鳴

          while(1)
          {
          for(i=0;i<8;i++) //8個(gè)LED
          {
          IO1DIR = LED; //當(dāng)前的LED設(shè)置為輸出
          IO1SET = LED; //當(dāng)前的LED熄滅
          DelayNS(100); //延時(shí)
          IO1CLR = LED; //當(dāng)前的LED點(diǎn)亮
          DelayNS(100); //延時(shí)
          IO1SET = LED; //當(dāng)前的LED熄滅
          LED =(LED<<1); //左移一位,
          }

          IO0CLR = BEEP; //8個(gè)LED點(diǎn)亮一遍后,蜂鳴器蜂鳴
          DelayNS(100); //延時(shí)
          IO0SET = BEEP; //蜂鳴器停止蜂鳴
          DelayNS(500); //延時(shí)
          LED = (1<<18);//為L(zhǎng)ED賦初值
          }

          return 0;
          }
          /*********************************************************************************************************
          ** End Of File
          ********************************************************************************************************/



          關(guān)鍵詞: LPC2131GPIO輸

          評(píng)論


          技術(shù)專區(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); })();