中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > I2C總線驅(qū)動(C51語言源程序)

        I2C總線驅(qū)動(C51語言源程序)

        作者: 時間:2013-01-07 來源:網(wǎng)絡(luò) 收藏

        /*****************停止總線****************/
        void Stop(void)
        {
        SCL=0;
        SDA=0;
        SCL=1;
        _nop_();
        _nop_();
        _nop_();
        SDA=1;
        _nop_();
        _nop_();
        _nop_();
        SCL=0;
        }

        /**************檢查應(yīng)答位*******************/
        bit RecAck(void)
        {
        SCL=0;
        SDA=1;
        SCL=1;
        _nop_();
        _nop_();
        _nop_();
        _nop_();
        CY=SDA; //因為返回值總是放在CY中的
        SCL=0;
        return(CY);
        }

        /***************對I2C總線產(chǎn)生應(yīng)答*******************/
        void I2CACK(void)
        {
        SDA=0;
        SCL=1;
        _nop_();
        _nop_();
        _nop_();
        _nop_();
        SCL=0;
        _nop_();
        SDA=1;
        }

        /*****************不對I2C總線產(chǎn)生應(yīng)答***************/
        void I2CNoAck(void)
        {
        SDA=1;
        SCL=1;
        _nop_();
        _nop_();
        _nop_();
        _nop_();
        SCL=0;
        }

        /*******************向I2C總線寫數(shù)據(jù)*********************/
        void I2CSendByte(unsigned char sendbyte)
        {
        unsigned char data j=8;
        for(;j>0;j--)
        {
        SCL=0;
        sendbyte=1; //無論C51怎樣實現(xiàn)這個操作,始終會使CY=sendbyte^7;
        SDA=CY;
        SCL=1;
        }
        SCL=0;
        }

        /**********************從I2C總線上讀數(shù)據(jù)子程序**********/
        unsigned char I2CReceiveByte(void)
        {
        register receivebyte,i=8;
        SCL=0;
        while(i--)
        {
        SCL=1;
        receivebyte=(receivebyte1)|SDA;
        SCL=0;
        }
        return(receivebyte);
        }

        /***************一個簡單延時程序************************/
        void Delay(unsigned char DelayCount)
        {
        while(DelayCount--);
        }

        void main()
        {
        // unsigned int i;
        //unsigned char j[32];
        unsigned char *pa,*pb,temp=0;
        unsigned char a[8]={5,6,7,8,9,10,11,12};
        unsigned char b[8]={0,0,0,0,0,0,0,0};
        pa=a[0];
        pb=b[0];
        P2_7=0;
        RW24XX(pa,8,0x0,writeI2C,M2401);
        RW24XX(pa,8,0x20,writeI2C,M2401);
        RW24XX(pb,8,0x20,readI2C,M2401);
        RW24XX(pb,8,0x30,writeI2C,M2401);
        // RW24XX(unsigned char *DataBuff,unsigned char ByteQuantity,unsigned int Address,
        // unsigned char ControlByte,enum eepromtype EepromType)
        while(1)
        {
        P2_7=1;
        }
        }


        上一頁 1 2 下一頁

        關(guān)鍵詞: I2C 總線驅(qū)動 C51語言

        評論


        相關(guān)推薦

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

        關(guān)閉