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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > pic168xa ADC程序(c語言)

          pic168xa ADC程序(c語言)

          作者: 時(shí)間:2016-11-18 來源:網(wǎng)絡(luò) 收藏
          #i nclude

          #i nclude <pic168xa.h>
          __CONFIG(0x1832);
          //芯片配置字,看門狗關(guān),上電延時(shí)開,掉電檢測關(guān),低壓編程關(guān),加密,4M晶體HS振蕩
          const char TABLE[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
          void DELAY();
          void DELAY11();
          void init();
          void display(unsigned int x);
          void main()
          {unsigned int result=0x0000;
          do
          {
          int i;
          result=0x0000;

          本文引用地址:http://www.ex-cimer.com/article/201611/315955.htm

          //for(i=4;i--;)
          // {
          init();
          DELAY();
          ADGO=0X01;

          while(ADGO)
          {result=ADRESH;
          result=result<<8;
          result=result+ADRESL;};
          // }
          // result=result>>3;
          for(i=10;--i;)
          {display(result);};
          //DELAY11();};

          }while(1);

          }
          void init()
          {
          TRISD=0X00;
          TRISB=0XE1;
          PORTD=0X00;
          ADCON1=0X8E;
          ADCON0=0XC1;
          DELAY();
          }
          void display(unsigned int x)
          {int qian,bai,shi,ge;
          unsigned int temp;
          temp=x;
          qian=temp/0x3e8;
          PORTD=TABLE[qian]; //查表得百位顯示的代碼
          PORTB=0xef; //RA3輸出低電平,點(diǎn)亮百位顯示
          // DELAY11();
          bai=(temp%0x3e8)/0x64;
          PORTD=TABLE[bai]; //查表得百位顯示的代碼
          PORTB=0xf7; //RA3輸出低電平,點(diǎn)亮百位顯示
          //DELAY11();
          shi=((temp%0x3e8)%0x64)/0xa; //延時(shí)一定時(shí)間,保證顯示亮度
          PORTD=TABLE[shi]; //查表得十位顯示的代碼
          PORTB=0xfb; //RA4輸出低電平,點(diǎn)亮十位顯示
          //DELAY11();
          ge=((temp%0x3e8)%0x64)%0xa; //延時(shí)一定時(shí)間,保證亮度
          PORTD=TABLE[ge]; //求個(gè)位顯示的代碼
          PORTB=0xfd; //RA5輸出低電平,點(diǎn)亮個(gè)位顯示
          DELAY11();
          }
          void DELAY()
          {
          int i;
          for(i=0x100;i--;);
          }
          void DELAY11()
          {
          int i;
          for(i=0;i<=30;i++)
          continue;
          }


          關(guān)鍵詞: pic168xaADC程序c語

          評論


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