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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AD轉(zhuǎn)換的數(shù)碼管顯示

          AD轉(zhuǎn)換的數(shù)碼管顯示

          作者: 時(shí)間:2012-09-18 來(lái)源:網(wǎng)絡(luò) 收藏
          *本例程采用芯片,硬件電路:cs片選端接P2.3,WR寫(xiě)數(shù)據(jù)端寫(xiě)P3.6,RD讀數(shù)據(jù)端接P3.7,鎖存端接P2.6腳,數(shù)碼管位選端分別接P3.2 ,P3.3,P3.4,段選端接P1口*/
          #includereg52.h>//頭文件#define uint unsigned int//宏文件#define uchar unsigned char//宏文件uchar num;//變量void delay3(uint z);//延時(shí)定義void dissy();//延時(shí)函數(shù)定義sbit ge=P3^2;//個(gè)位定義sbit shi=P3^3;//十位定義sbit bai=P3^4;//百位定義sbit ad_cs=P2^3;//片選端sbit ad_wr=P3^6;//寫(xiě)數(shù)據(jù)端sbit ad_rd=P3^7;//讀數(shù)據(jù)端sbit pian=P2^6;//鎖存器片選void add();//ad轉(zhuǎn)換子函數(shù)void delay(uint i);//延時(shí)子函數(shù)申明uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};//數(shù)組/************主函數(shù)**********/void main(){while(1){add();//調(diào)用子函數(shù)dissy();//子函數(shù)  }   }/************子函數(shù)**********/void add()//子函數(shù){uchar i;ad_cs=1;//將片選關(guān)閉ad_cs=0;//將片選打開(kāi)ad_wr=1;//寫(xiě)數(shù)上升沿ad_wr=0;//寫(xiě)數(shù)下降沿ad_wr=1;//寫(xiě)數(shù)上升沿P1=0xff;//送數(shù)到P0口ad_rd=1;//讀數(shù)上升沿delay(25);//延時(shí)一會(huì)兒ad_rd=0;//讀數(shù)下降沿//////**************因?yàn)锳D轉(zhuǎn)換時(shí)間周期長(zhǎng),
          我現(xiàn)在的數(shù)碼管沒(méi)有采用鎖存器,AD轉(zhuǎn)換時(shí)間大于顯示時(shí)間,
          所以顯示時(shí)會(huì)閃爍,解決此問(wèn)題方法是,連續(xù)調(diào)用了顯示子程序七次,
          這樣顯示時(shí)就和AD轉(zhuǎn)換時(shí)一至,顯示出來(lái)的數(shù)就不閃了********************//////for(i=0;i7;i++)                //調(diào)用7次,相當(dāng)于delay(255)void dissy();//////**********************************//////num=P1;//將數(shù)給計(jì)數(shù)器num}/************顯示子函數(shù)**********/void  dissy()//顯示子函數(shù){ P0=table[num/100];//百位顯示數(shù)據(jù)bai=0;//百位打開(kāi)delay(14);//延時(shí)一會(huì)bai=1;//關(guān)閉百位P0=table[num%100/10];//十位顯示數(shù)據(jù)shi=0;//十位打開(kāi)delay(14);//延時(shí)一會(huì)shi=1;//關(guān)閉十位P0=table[num%10];//百位顯示數(shù)據(jù)ge=0;//關(guān)閉十位delay(14);//延時(shí)一會(huì)ge=1;//關(guān)閉十位}/**************延時(shí)子函數(shù)*************/void delay(uint i)//延時(shí)函數(shù)      {uint j,k;//定義變量for(j=i;j>0;j--)//外循環(huán)for(k=30;k>0;k--);//內(nèi)循環(huán)}


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