在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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)用 > 通過I2C芯片EEPRON24C02控制P1口

            通過I2C芯片EEPRON24C02控制P1口

            作者: 時間:2016-11-30 來源:網(wǎng)絡(luò) 收藏
            通過芯片AT24C02控制P1口。程序:

            #include
            sbit sda=P2^1;
            sbit scl=P2^0;
            void delay1()
            {
            ;;;
            }

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

            void delay()
            {
            int x,y;
            for(x=0;x<5;x++)
            for(y=0;y<120;y++);
            }
            void start()
            {sda=1;
            delay1();
            scl=1;
            delay1();
            sda=0;
            delay1();
            }
            void stop()
            {
            sda=0;
            delay1();
            scl=1;
            delay1();
            sda=1;
            delay1();
            }
            void respons()
            {
            sda=0;
            delay1();
            scl=1;
            delay1();
            scl=0;
            delay1();
            }
            void init()
            {
            sda=1;
            scl=1;
            }
            void write_byte(unsigned char date)
            {
            unsigned char temp,i;
            temp=date;
            scl=0;
            delay1();
            for(i=0;i<8;i++)
            {
            temp=temp<<1;
            sda=CY;
            delay1();
            scl=1;
            delay1();
            scl=0;
            delay1();
            }
            sda=1;
            delay1();
            }
            unsigned char read_byte()
            {
            unsigned char i,j,k;
            scl=0;
            delay1();
            sda=1;
            delay1();
            for(i=0;i<8;i++)
            {
            scl=1;
            delay1();
            j=sda;
            k=(k<<1)|j;
            scl=0;
            delay1();
            }
            return k;
            }

            void write_add(unsigned char addres,unsigned char date)
            {
            start();
            write_byte(0xae);
            respons();
            write_byte(addres);
            respons();
            write_byte(date);
            respons();
            stop();

            }
            unsigned char read_add(unsigned char address)
            {unsigned char date;
            start();
            write_byte(0xae);
            respons();
            write_byte(address);
            respons();
            start();
            write_byte(0xaf);
            respons();
            date=read_byte();
            stop();
            return date;
            }
            void main()
            {
            init();
            write_add(3,0x55);
            delay();
            P1=read_add(3);
            while(1);
            }



            關(guān)鍵詞: I2C芯片EEPRON24C0

            評論


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

            關(guān)閉