色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

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

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

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

          請(qǐng)以下面程序?yàn)槔忉尳忉?/p>本文引用地址:http://cafeforensic.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//計(jì)數(shù)溢出,CPU響應(yīng)中斷
          {
          TH0=(65536-50000)/256;
          TL0=(65536-50000)%6;//設(shè)定回計(jì)數(shù)初值,但此時(shí)計(jì)數(shù)溢出后已清0仍在計(jì)數(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++;
          }
          }



          評(píng)論


          技術(shù)專(zhuān)區(qū)

          關(guān)閉