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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > C8051F(330)精確延時(shí)程序(24.5M)

          C8051F(330)精確延時(shí)程序(24.5M)

          作者: 時(shí)間:2016-11-23 來(lái)源:網(wǎng)絡(luò) 收藏
          //**********************************************

          // 功能:C8051F(330)精確延時(shí) 24.5M

          //**********************************************
          #include
          #include
          //----------------------------------------------
          void Reset_Sources_Init()
          {
          RSTSRC = 0x04;
          }

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

          void PCA_Init()
          {
          PCA0MD &= ~0x40;
          PCA0MD = 0x00;
          }

          void Port_IO_Init()
          {
          P2MDOUT = 0x01;
          XBR1 = 0x40;
          }

          void Oscillator_Init()
          {
          OSCICN = 0x83;
          }

          void Init_Device(void)
          {
          Reset_Sources_Init();
          PCA_Init();
          Port_IO_Init();
          Oscillator_Init();
          }

          //----------------------------
          // 微秒級(jí)精確延時(shí)
          // 仿真:(24.5M)
          // delay_us(1); //1.72us
          // delay_us(10); //10.89us
          // delay_us(100); //102.74us
          //----------------------------
          void delay_us(unsigned char k)
          {
          while(k--)
          {
          _nop_();_nop_();_nop_();_nop_();
          _nop_();_nop_();_nop_();_nop_();
          _nop_();_nop_();_nop_();_nop_();
          _nop_();_nop_();_nop_();_nop_();
          }
          }
          //----------------------------------------------
          // 毫秒級(jí)精確延時(shí)
          // 仿真:(24.5M)
          // delay_ms(1); //1001.75us
          // delay_ms(10); //10.008ms
          // delay_ms(100); //老機(jī)太慢出不來(lái)鳥~自己測(cè)吧:)
          //----------------------------------------------
          void delay_1ms()
          {
          unsigned int j ;
          for(j=3060;j>0;j--);
          }
          void delay_ms(unsigned int i)
          {
          for(;i>0;i--)delay_1ms();
          }
          //------------------------------------------
          void main()
          {
          Init_Device();
          while(1)
          {
          delay_us(1);
          delay_us(10);
          delay_us(100);
          delay_ms(1);
          delay_ms(10);
          delay_ms(100);
          P2^=0x01;
          }
          }



          關(guān)鍵詞: C8051精確延時(shí)24.5

          評(píng)論


          相關(guān)推薦

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