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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應用 > DA轉(zhuǎn)換-15~15v電壓源設(shè)計

          DA轉(zhuǎn)換-15~15v電壓源設(shè)計

          作者: 時間:2016-11-17 來源:網(wǎng)絡(luò) 收藏
          #include
          #include
          #include
          #define uchar unsigned char
          #define uint unsigned int
          float num=51;
          float temp;
          uchar val;
          uchar aa[4];

          unsigned char code disp_code[]={
          0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
          0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xbf,0xff};//數(shù)碼管顯示
          /**********************************************************

          延時子函數(shù)

          **********************************************************/
          void delayms(uint ms)
          {
          uchar t;
          while(ms--)
          {
          for(t = 0; t < 120; t++);
          }
          }



          /******************************************************************
          函數(shù)功能:顯示計數(shù)次數(shù)的子程序
          入口參數(shù):x
          ********************************************************************/
          void Display(void)
          { uchar i;
          P2=0xfe ;
          for(i=0;i<4;i++)
          { P1=disp_code[aa[i]];
          if(P2==0xfb)
          P1=disp_code[aa[i]]&0x7f;
          delayms(5);
          P2=_crol_(P2,1);
          }

          }

          /*******************************************
          函數(shù)功能:主函數(shù)
          ******************************************/
          void main(void)
          {
          EA=1; //開放總中斷
          EX0=EX1=1; //允許使用外中斷
          IT0=IT1=1; //選擇負跳變來觸發(fā)外中斷
          temp=num/8.5;
          val=(uchar)temp;
          if(val<15)
          {aa[0]=16;val=15-val;}
          else {aa[0]=17;val=val-15;}
          aa[1]=val/10;
          if (aa[1]==0)
          aa[1]=17;
          aa[2]=val%10;
          aa[3]=0;
          P0=(uchar)num;
          while(1)
          Display();

          }

          void int0(void) interrupt 0 //外中斷0的中斷編號為0
          {
          if(num==0)
          num=num+8.5;
          num=num-8.5;
          temp=num/8.5;
          val=(uchar)temp;
          if(val<15)
          {aa[0]=16;val=15-val;}
          else {aa[0]=17;val=val-15;}
          aa[1]=val/10;
          if (aa[1]==0)
          aa[1]=17;
          aa[2]=val%10;
          aa[3]=0;
          }
          void int1(void) interrupt 2 //外中斷1的中斷編號為0
          {

          if(num==255)
          num=num-8.5;
          num=num+8.5;
          temp=num/8.5;
          val=(uchar)temp;
          if(val<15)
          {aa[0]=16;val=15-val;}
          else {aa[0]=17;val=val-15;}
          aa[1]=val/10;
          if (aa[1]==0)
          aa[1]=17;
          aa[2]=val%10;
          aa[3]=0;
          P0=(uchar)num;
          }


          關(guān)鍵詞: DA轉(zhuǎn)換-15~15v電壓

          評論


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