在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 基于51單片機的波形發(fā)生器&DA轉(zhuǎn)換(dac0832)

            基于51單片機的波形發(fā)生器&DA轉(zhuǎn)換(dac0832)

            作者: 時間:2016-11-17 來源:網(wǎng)絡(luò) 收藏
            代碼如下:

            #include"reg51.h"
            #define uchar unsigned char
            sbit ksaw=P2^0; //鋸齒波按鍵.
            sbit ktran=P2^1; //三角波按鍵.
            sbit ksquare=P2^2; //方波按鍵.
            sbit ksin=P2^3; //正弦波按鍵.

            本文引用地址:http://www.biyoush.com/article/201611/315465.htm

            uchar key1;
            uchar keya;
            uchar keyb;
            uchar keyc;
            uchar keyd;void delay( );
            uchar code tab[128]={
            64,67,70,73,76,79,82,85,88,91,94,96,99,102,104,106,
            109,111,113,115,117,118,120,121,123,124,125,126,126,
            127,127,127,127,127,127,127,126,126,125,124,123,121,
            120,118,117,115,113,111,109,106,104,102,99,96,94,91,
            88,85,82,79,76,73,70,67,64,60,57,54,51,48,45,42,39,
            36,33,31,28,25,23,21,18,16,14,12,10,9,7,6,4,3,2,1,
            1,0,0,0,0,0,0,0,1,1,2,3,4,6,7,9,10,12,14,16,18,21,23,
            25,28,31,33,36,39,42,45,48,51,54,57,60};

            void delay( )
            {
            uchar i;
            for(i=0;i<255;i++);
            }
            void saw(void) //鋸齒波.
            {
            uchar i;
            while(1)
            {
            if(keya==1)
            {
            for(i=0;i<255;i++)
            P0=i;
            }
            else break;
            }
            }
            void tran(void) //三角波
            {
            uchar i;
            while(1)
            {
            if(keyb==1)
            {
            for(i=0;i<255;i++)
            P0=i;
            for(i=255;i>0;i--)
            P0=i;
            }
            else break;
            }
            }
            void square(void) //方波
            {
            while(1)
            {
            if(keyc==1)
            {
            P0=0x00;
            delay();
            P0=0xff;
            delay();
            }
            else break;
            }

            }

            void sin( ) //正弦波
            {
            unsigned int i=0;
            while(1)
            {
            if(keyd==1)
            {
            if(++i==128)i=0;
            {P0=tab[i];}
            }
            else break;
            }
            }
            void main(void) //主函數(shù)
            {
            EA=1;
            EX0=1;
            while(1)
            {
            if(key1)
            {
            switch(key1)
            {
            case 0x01:
            //P0=0XC0;//
            saw();
            break;
            case 0x02:
            //P0=0XC0;//
            tran();
            break;
            case 0x03:
            //P0=0XBE;//
            square();
            break;
            case 0x04:
            //P0=0XB6;//
            sin();
            break;
            }
            }
            }

            }

            void int0(void)interrupt0 using 1
            {
            if(ksaw==0)
            {key1=0x01;keya=1;keyb=0;keyc=0;keyd=0;}
            if(ktran==0)
            {key1=0x02;keya=0;keyb=1;keyc=0;keyd=0;}
            if(ksquare==0)
            { key1=0x03;keya=0;keyb=0;keyc=1;keyd=0;}
            if(ksin==0)
            {key1=0x04;keya=0;keyb=0;keyc=0;keyd=1;}
            }

            圖片如下:



            評論


            技術(shù)專區(qū)

            關(guān)閉