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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機,計數(shù)溢出

          51單片機,計數(shù)溢出

          作者: 時間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
          51單片機,計數(shù)溢出,CPU響應(yīng)中斷,執(zhí)行中斷函數(shù)過程中,計數(shù)器是否已清0開始計數(shù),還是等CPU執(zhí)行完中斷函數(shù)后再計數(shù),

          請以下面程序為例解釋解釋

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

          //用T0使隔1秒流水燈亮一次,用T1使隔2秒靜態(tài)數(shù)碼管依次顯示數(shù)字
          #include
          #include
          #define uint unsigned int
          #define uchar unsigned char
          uchar tcount0,tcount1,temp,num;
          uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,
          0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
          void main()
          {
          TMOD=0x11;
          TH0=(65536-50000)/256;
          TL0=(65536-50000)%6;
          TH1=(65536-50000)/256;
          TL1=(65536-50000)%6;
          EA=1;
          ET0=1;
          ET1=1;
          num=0;
          temp=0xfe;
          tcount0=0;
          tcount1=0;
          TR0=1;
          TR1=1;
          while(1);
          }
          void t0() interrupt 1//計數(shù)溢出,CPU響應(yīng)中斷
          {
          TH0=(65536-50000)/256;
          TL0=(65536-50000)%6;//設(shè)定回計數(shù)初值,但此時計數(shù)溢出后已清0仍在計數(shù)嗎?
          tcount0++;
          if(tcount0==20)
          {
          tcount0=0;
          P1=temp;
          temp=_crol_(temp,1);
          }
          }
          void t1() interrupt 3
          {
          TH1=(65536-50000)/256;
          TL1=(65536-50000)%6;
          tcount1++;
          if(tcount1==40)
          {
          tcount1=0;
          if (num==16)
          num=0;
          P0=table[num];
          num++;
          }
          }



          關(guān)鍵詞: 51單片機計數(shù)溢

          評論


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