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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 89C52單片機(jī)制作秒表

          89C52單片機(jī)制作秒表

          作者: 時間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
          用STC公司的89C52單片機(jī)制作秒表,過程其實很簡單,有以下幾個注意的東西;
          1. 動態(tài)顯示
          2. 七段譯碼的編碼表
          3. 定時器的設(shè)置
          單片機(jī)的時鐘信號為11.0592MHz,選取46080對應(yīng)0.05s。
          程序:
          #include
          #include
          sbit P2_2=P2^2 ;
          sbit P2_3=P2^3 ;
          void delay(unsigned char dly)
          {
          unsigned char i,j;
          for(i=255;i>0;i--)
          for(j=dly;j>0;j--)
          ;
          }
          unsigned char num,time;
          void timer0()interrupt 1
          {
          TH0=(65535-46080)/256;
          TL0=(65535-46080)% 256;
          num++;
          if(num==20)
          {
          num=0;
          time++;
          }
          }
          void intial()
          {
          TMOD=0x01;
          ET0=1;
          EA=1;
          TR0=1;
          num=0;
          }
          void main()
          {
          unsigned char table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
          unsigned char shi,fen;
          intial();
          while(1)
          {
          if(time==60)
          time=0;
          shi=time/10;
          fen=time% 10;
          P2_2=1;
          P2_3=0;
          P0=table[shi];
          delay(2);
          P2_2=0;
          P2_3=1;
          P0=table[fen];
          delay(2);
          }
          }



          關(guān)鍵詞: 89C52單片機(jī)制作秒

          評論


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