日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 99秒計(jì)時(shí)+99秒倒計(jì)時(shí)(中斷觸發(fā)定時(shí)器)

          99秒計(jì)時(shí)+99秒倒計(jì)時(shí)(中斷觸發(fā)定時(shí)器)

          作者: 時(shí)間:2012-09-04 來源:網(wǎng)絡(luò) 收藏

          ___________________________________________

          本文引用地址:http://yuyingmama.com.cn/article/170922.htm

          功能:99秒

          時(shí)間2010—7—18

          ___________________________________________

          #includereg52.h>


          code unsigned char tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

          unsigned char Dis_Shiwei;
          unsigned char Dis_Gewei;

          void delay(unsigned int cnt)
          {
          while(--cnt);
          }

          main()
          {

          TMOD |=0x01; //10ms in 12M crystal,工作在模式一,16位
          TH0=0xd8;
          TL0=0xf0;
          IE= 0x82; //打開
          TR0=1; //打開定時(shí)開關(guān)

          while(1)
          {
          P0=Dis_Shiwei;
          P2=0;
          delay(300);
          P0=Dis_Gewei;
          P2=1;
          delay(300);
          }

          }

          void tim(void) interrupt 1 using 1
          {
          static unsigned char second,count;
          TH0=0xd8;
          TL0=0xf0;

          count++;
          if (count==100) //100x10ms
          {
          count=0;
          second++;
          if(second==100)
          second=0;
          Dis_Shiwei=tab[second/10];
          Dis_Gewei=tab[second%10];

          }

          }


          /*

          設(shè)定為:TH0=0xd8;TL0=0xf0;經(jīng)確定時(shí)10ms。從程序開始執(zhí)行,每當(dāng)主程序中的16位數(shù)發(fā)生溢出則,主程序保護(hù)現(xiàn)場并調(diào)用子程序,也可以寫為:TH0=(65536-10000)/256;TL0=(65536-10000)%256。秒脈沖的產(chǎn)生要求精確定時(shí)1s,實(shí)際情況可能有延誤。


          1 0000 0000 0000 0000

          1101 1000 1111 0000

          ————————————

          0010 0111 0001 0000

          Time=16(1+16+32+64+512)=16*625=10000us=10ms

          紅外遙控器相關(guān)文章:紅外遙控器原理

          上一頁 1 2 下一頁

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉