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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 發(fā)光二極管閃爍程序(位操作)

          發(fā)光二極管閃爍程序(位操作)

          作者: 時(shí)間:2016-11-17 來(lái)源:網(wǎng)絡(luò) 收藏
          //位操作點(diǎn)亮發(fā)光二極管

          #include
          #include
          sbit D2=P1^3;
          void OSCILLATOR_Init(void)
          {
          U8 SFRPAGE_save = SFRPAGE;
          SFRPAGE = CONFIG_PAGE;
          OSCICN = 0x87; // Set internal osc. divider to 1

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

          SFRPAGE = SFRPAGE_save;
          }
          void PORT_Init(void)
          {
          U8 SFRPAGE_save = SFRPAGE;
          SFRPAGE = CONFIG_PAGE;
          P1MDIN |= 0x08; // P1.3 is digital
          P1MDOUT = 0x08;
          XBR2 = 0x40; // Enable crossbar and GLOBAL enable weak pull-ups
          SFRPAGE = SFRPAGE_save;
          }
          /*void Delay(unsigned m)
          {
          char i=0;
          while(--m)
          {
          for(i=0;i<120;i++);//修改i的最大值來(lái)調(diào)整延時(shí)時(shí)間,延時(shí)時(shí)間計(jì)算:
          }

          }*/
          //延時(shí)可以使用上面的或下面的雙層for循環(huán),單層時(shí)間太短
          void delay()
          {
          unsigned int i;
          unsigned char j;
          for(i=1;i<3000;i++)
          {
          for(j=1;j<120;j++);
          }

          }
          void main()
          {
          OSCILLATOR_Init();//時(shí)鐘初始化
          PORT_Init();//端口初始化
          PCA0MD &= ~0x40; //禁止看門(mén)狗
          D2=1;
          //Delay(1200);
          delay();
          D2=0;
          delay();
          //Delay(1200);
          }



          評(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); })();