在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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è)計(jì)應(yīng)用 > 單片機(jī)模擬IIC總線與EEPROM進(jìn)行數(shù)據(jù)通信

            單片機(jī)模擬IIC總線與EEPROM進(jìn)行數(shù)據(jù)通信

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

            #define uchar unsigned char
            sbit sda=P2^0;
            sbit scl=P2^1;
            uchar a;
            void delay()
            { ;; }
            void start() //開始信號(hào)
            {
            sda=1;
            delay();
            scl=1;
            delay();
            sda=0;
            delay();
            }

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

            void stop() //停止
            {
            sda=0;
            delay();
            scl=1;
            delay();
            sda=1;
            delay();
            }

            void respons() //應(yīng)答
            {
            uchar i;
            scl=1;
            delay();
            while((sda==1)&&(i<250))i++;
            scl=0;
            delay();
            }

            void init()
            {
            sda=1;
            delay();
            scl=1;
            delay();
            }

            void write_byte(uchar date)
            {
            uchar i,temp;
            temp=date;


            for(i=0;i<8;i++)
            {
            temp=temp<<1;
            scl=0;
            delay();
            sda=CY;
            delay();
            scl=1;
            delay();
            //scl=0;
            // delay();
            }
            scl=0;
            delay();
            sda=1;
            delay();
            }

            uchar read_byte()
            {
            uchar i,k;
            scl=0;
            delay();
            sda=1;
            delay();
            for(i=0;i<8;i++)
            {
            scl=1;
            delay();
            k=(k<<1)|sda;
            scl=0;
            delay();
            }
            return k;
            }

            void delay1(uchar x)
            {
            uchar a,b;
            for(a=x;a>0;a--)
            for(b=100;b>0;b--);
            }

            void write_add(uchar address,uchar date)
            {
            start();
            write_byte(0xa0);
            respons();
            write_byte(address);
            respons();
            write_byte(date);
            respons();
            stop();
            }

            uchar read_add(uchar address)
            {
            uchar date;
            start();
            write_byte(0xa0);
            respons();
            write_byte(address);
            respons();
            start();
            write_byte(0xa1);
            respons();
            date=read_byte();
            stop();
            return date;
            }

            void main()
            {
            init();
            write_add(23,0xaa);
            delay1(100);
            P1=read_add(23);
            while(1);
            }



            評(píng)論


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

            關(guān)閉