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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)計(jì)數(shù)器T0作定時(shí)技術(shù)

          單片機(jī)計(jì)數(shù)器T0作定時(shí)技術(shù)

          作者: 時(shí)間:2013-03-12 來(lái)源:網(wǎng)絡(luò) 收藏

          6.匯編源程序(查詢法)

          SECOND EQU 30H

          TCOUNT EQU 31H

          ORG 00H

          START: MOV SECOND,#00H

          MOV TCOUNT,#00H

          MOV TMOD,#01H

          MOV TH0,#(65536-50000) / 256

          MOV TL0,#(65536-50000) MOD 256

          SETB TR0

          DISP: MOV A,SECOND

          MOV B,#10

          DIV AB

          MOV DPTR,#TABLE

          MOVC A,@A+DPTR

          MOV P0,A

          MOV A,B

          MOVC A,@A+DPTR

          MOV P2,A

          WAIT: JNB TF0,WAIT

          CLR TF0

          MOV TH0,#(65536-50000) / 256

          MOV TL0,#(65536-50000) MOD 256

          INC TCOUNT

          MOV A,TCOUNT

          CJNE A,#20,NEXT

          MOV TCOUNT,#00H

          INC SECOND

          MOV A,SECOND

          CJNE A,#60,NEX

          MOV SECOND,#00H

          NEX: LJMP DISP

          NEXT: LJMP WAIT

          TABLE: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH

          END

          7. C語(yǔ)言源程序(查詢法)

          #include AT89X51.H>

          unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,

          0x66,0x6d,0x7d,0x07,

          0x7f,0x6f,0x77,0x7c,

          0x39,0x5e,0x79,0x71,0x00};

          unsigned char second;

          unsigned char tcount;

          void main(void)

          {

          TMOD=0x01;

          TH0=(65536-50000)/256;

          TL0=(65536-50000)%6;

          TR0=1;

          tcount=0;

          second=0;

          P0=dispcode[second/10];

          P2=dispcode[second];

          while(1)

          {

          if(TF0==1)

          {

          tcount++;

          if(tcount==20)

          {

          tcount=0;

          second++;

          if(second==60)

          {

          second=0;

          }

          P0=dispcode[second/10];

          P2=dispcode[second];

          }

          TF0=0;

          TH0=(65536-50000)/256;

          TL0=(65536-50000)%6;

          }

          }

          }

          51單片機(jī)相關(guān)文章:51單片機(jī)教程


          單片機(jī)相關(guān)文章:單片機(jī)教程


          單片機(jī)相關(guān)文章:單片機(jī)視頻教程


          單片機(jī)相關(guān)文章:單片機(jī)工作原理


          塵埃粒子計(jì)數(shù)器相關(guān)文章:塵埃粒子計(jì)數(shù)器原理


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