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

          新聞中心

          幾個(gè)延時(shí)子程序

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

          延時(shí)時(shí)間為:8*i+10 us
          要求延時(shí)1ms i=124時(shí) 延時(shí)為1002us 誤差2us
          2ms i=249時(shí) 延時(shí)為2002us 誤差2us
          **************************************/

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

          void delay(unsigned char i)
          {
          for(;i>0;--i);

          }

          /**************************************
          延時(shí)時(shí)間為:6*i+11 us
          要求延時(shí)1ms i=165時(shí) 延時(shí)為1001us 誤差1us
          2ms i=331時(shí) 延時(shí)為1997us 誤差3us

          **************************************/

          void delay(unsigned char i)
          {
          while(i--);

          }

          /**************************************
          延時(shí)時(shí)間為:2*i+5 us

          **************************************/

          void delay(unsigned char i)
          {
          while(--i);

          }

          以上如果加上了n個(gè)_nop_(),需將i換為(i+n);

          /**************************************
          延時(shí)時(shí)間為:20us*t+13us
          **************************************/
          void delay_20us(unsigned int t)
          {
          unsigned char j;
          for(;t>0;t--)
          for(j=4;j>0;j--);
          }

          /**************************************
          延時(shí)時(shí)間為:50us*t+13us
          **************************************/
          void delay_50us(unsigned int t)
          {
          unsigned char j;
          for(;t>0;t--)
          for(j=19;j>0;j--);
          }

          /**************************************
          延時(shí)時(shí)間為:100us*t+13us
          **************************************/
          void delay_100us(unsigned int t)
          {
          unsigned char j;
          for(;t>0;t--)
          for(j=44;j>0;j--);
          }

          /**************************************
          延時(shí)時(shí)間為:978count*n+21us
          要求延時(shí)1ms count=1時(shí) 延時(shí)為999us 誤差1us
          2ms count=2時(shí) 延時(shí)為1977us 誤差23us
          **************************************/
          void delay1ms(int count)
          {
          int x,y;
          for(x=0;x for(y=0;y<120;y++);
          }



          關(guān)鍵詞: 延時(shí)子程

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