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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > stc12c5a60s2單片機(jī)spwm發(fā)生程序帶仿真文件

          stc12c5a60s2單片機(jī)spwm發(fā)生程序帶仿真文件

          作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
          包含文件和仿真文件的下載地址:http://www.51hei.com/f/stc12c5a60s2_spwm.zip

          下面是主程序部分:
          #include
          #include

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

          #define uint unsigned int

          uchar index;
          uchar a;
          void init_pca(void)//pca計(jì)數(shù)器初始化函數(shù)

          {

          CMOD=0x04;//計(jì)數(shù)器0的溢出為PCA計(jì)數(shù)器的時(shí)鐘源

          CCON=0x00;

          CCAPM0=0x42;//8位PWM輸出,無(wú)中斷

          CL=0x00;//清零pca計(jì)數(shù)器

          CH=0x00;

          CCAP0L=pwm[0]; //初始化spwm輸出的占空比

          CCAP0H=pwm[0];

          CR=1;//運(yùn)行adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=25357d4a26439b28&k=pca&k0=pca&kdi0=0&luki=3&n=10&p=baidu&q=98059059_cpr&rb=0&rs=1&seller_id=1&sid=289b43264a7d3525&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1831118&u=http%3A%2F%2Fwww%2E51hei%2Ecom%2Fmcu%2F2118%2Ehtml&urlid=0" id="5_nwl" mpid="5" target="_blank">pca計(jì)數(shù)器

          }

          void init_timer(void)//計(jì)數(shù)器初始化函數(shù)

          {

          TMOD= 0x12; //計(jì)數(shù)器0工作在方式模式2,計(jì)數(shù)器1工作在方式1

          TH0 = 0xFF;//T0的計(jì)數(shù)值為5,把時(shí)鐘源5分頻

          TL0 = 0xFF;

          TH1 = 0xF6;//T1的計(jì)數(shù)值為625,若是12M晶振,則中斷頻率為12M/625=1920HZ,正弦頻率為1920/32=600HZ,即600/12=50HZ

          TL1 = 0xA0; //T1的計(jì)數(shù)值低位

          AUXR=0x80;//計(jì)數(shù)器均工作在8051速度

          //ET0 = 1; //開(kāi)中計(jì)數(shù)器0斷

          ET1 = 1; //開(kāi)計(jì)數(shù)器1中斷

          TR0 = 1; //開(kāi)啟計(jì)數(shù)器0

          TR1 = 1; //開(kāi)計(jì)數(shù)器1

          }

          void int_timer1(void) interrupt 3//計(jì)數(shù)器1中斷函數(shù)

          {

          CR=0;
          a=a+1;
          index++; //查表索引

          TH1=0xFD; //重裝計(jì)數(shù)值

          TL1=0x8F;

          CCAP0H=pwm[index%32]*2;//改變pwm的占空比

          CR=1;

          }
          void main()
          {a=0;
          EA=1;//開(kāi)總中斷
          init_pca();
          init_timer();
          while(1);
          //-.-//
          }



          關(guān)鍵詞: stc12c5a60s2單片機(jī)spw

          評(píng)論


          技術(shù)專(zhuān)區(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); })();