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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 單片機流水線計數(shù)器設計

          單片機流水線計數(shù)器設計

          作者: 時間:2016-12-01 來源:網(wǎng)絡 收藏
          幾年晚上一個網(wǎng)友找我做流水線計數(shù)器,于是想起了半年前我上傳到百度文庫的這個文檔。呵呵,當年

          濰坊學院第二屆電子設計大賽

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

          #include

          #define uint unsigned int

          #define uchar unsigned char

          uchar code tabel[]={ 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};//這個數(shù)組存放0~9

          uint counter;//定義計數(shù)器,用來計量脈沖次數(shù)

          sbit wei_ge=P1^0; //定義位選引腳

          sbit wei_shi=P1^1;

          sbit wei_bai=P1^2;

          sbit wei_qian=P1^3;

          sbit BUZZER=P2^0;

          void delay_(unsigned int j)

          {

          unsigned int k;

          while (--j!=0)

          {

          for (k=0;k<600;k++);

          }

          }

          /*延時子程序*******************************************************/

          void delay(uint xms)

          {

          uint j;

          for(;xms>0;xms--)

          for(j=110;j>0;j--);

          }

          /*數(shù)碼管掃描顯示子程序************************************************/

          void shuma_show(uint date)

          {

          uchar ge,shi,bai,qian;//數(shù)碼管顯示變量聲明

          ge=date%10;//個位數(shù)換算

          shi=date/10%10;//十位換算

          bai=date/100%10;//百位換算

          qian=date/1000;//千位換算

          wei_ge=1;//打開個位顯示

          P0=tabel[ge]; //數(shù)據(jù)輸入數(shù)碼管內(nèi)

          delay(2);//延時顯示2ms

          wei_ge=0;//關閉個位顯示

          wei_shi=1;//打開個位顯示

          P0=tabel[shi]; //數(shù)據(jù)輸入數(shù)碼管內(nèi)

          delay(2);//延時顯示2ms

          wei_shi=0;//關閉個位顯示

          wei_bai=1;//打開個位顯示

          P0=tabel[bai]; //數(shù)據(jù)輸入數(shù)碼管內(nèi)

          delay(2);//延時顯示2ms

          wei_bai=0;//關閉個位顯示

          wei_qian=1;//打開個位顯示

          P0=tabel[qian]; //數(shù)據(jù)輸入數(shù)碼管內(nèi)

          delay(2);//延時顯示2ms

          wei_qian=0;//關閉個位顯示

          }

          /*初始化子程序**********************************************************/

          void inti()

          {

          wei_ge=wei_shi=wei_bai=wei_qian=0;//各I/O口初始化

          TMOD=0x05;//設置計數(shù)器0工作方式1,為16位計數(shù)器,且為外部計數(shù)

          TH0=0;//計數(shù)器高8位裝0

          TL0=0;//計數(shù)器低8位裝0

          TR0=1;//開計數(shù)器

          }

          /*主程序***************************************************************/

          void main()

          {

          BUZZER=0;

          inti();

          while(1)

          {

          counter=TH0*255+TL0;//讀計數(shù)器數(shù)據(jù)

          }

          if(counter==1000)

          {

          TH0=TL0=0;

          } //計滿清零

          shuma_show(counter);//數(shù)碼管掃描顯示

          if((counter%100==0)&& counter!=0)//逢百提醒

          {

          BUZZER=1;

          delay(500);

          BUZZER=1;

          }

          }

          }



          評論


          技術專區(qū)

          關閉
          看屁屁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); })();