在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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) > 設計應用 > MSP430模擬IIC接口程序

            MSP430模擬IIC接口程序

            作者: 時間:2016-11-22 來源:網(wǎng)絡 收藏
            1-簡介
            MSP430單片機普通II模擬IIC接口程序范例。

            2-程序例程

            #include "MSP430x14x.h"

            //P3.2 SCL

            //P3.3 SDA

            #define SDA_1 P3OUT |= BIT3 //SDA = 1

            #define SDA_0 P3OUT &=~ BIT3 //SDA = 0

            #define SCL_1 P3OUT |= BIT2 //SCL = 1

            #define SCL_0 P3OUT &=~ BIT2 //SCL = 0

            #define DIR_IN P3DIR &=~ BIT3; SDA_1//I/O口為輸入

            #define DIR_OUT P3DIR |= BIT3 //I/0口為輸出

            #define SDA_IN ((P3IN >> 3) & 0x01) //Read SDA

            unsigned int a[50];

            /
            {
            TempBit = 1;
            }
            else
            {
            TempBit = 0;
            }
            DIR_OUT;
            TempData = (TempData << 1) | TempBit;
            SCL_0;
            }
            Delay(5);
            return(TempData);
            }

            /) && (i < 255))
            {
            i++;
            }
            DIR_OUT;
            SCL_0;
            Delay(5);
            }

            /)
            {
            unsigned char HighData = 0;
            unsigned char LowData = 0;
            unsigned int TempData = 0;
            Start();
            WriteByte(0xa0);
            ReceiveAck();
            WriteByte(unit);
            ReceiveAck();
            Start();
            WriteByte(0xa1);
            ReceiveAck();
            LowData = ReadByte();
            Acknowledge();
            HighData = ReadByte();
            Stop();
            TempData = (HighData << 8) + LowData;
            Delay(1000);
            return(TempData);
            }

            /
            {
            unsigned char i;
            unsigned char HighData = 0;
            unsigned char LowData = 0;
            unsigned int TempData = 0;
            Start();
            WriteByte(0xa0);
            ReceiveAck();
            WriteByte(unit);
            ReceiveAck();
            Start();
            WriteByte(0xa1);
            ReceiveAck();
            for (i=0; i<49; i++)
            {
            LowData = ReadByte();
            Acknowledge();
            HighData = ReadByte();
            Acknowledge();
            a[i]= (HighData << 8) + LowData;
            }
            LowData = ReadByte();
            Acknowledge();
            HighData = ReadByte();
            Stop();
            a[49] = (HighData << 8) + LowData;
            Delay(1000);
            }

            /, unsigned int WriteData)
            {
            unsigned char LowData = 0;
            unsigned char HighData = 0;
            LowData = (unsigned char)WriteData;
            HighData = (unsigned char)(WriteData >> 8);
            Start();
            WriteByte(0xa0);
            ReceiveAck();
            WriteByte(unit);
            ReceiveAck();
            WriteByte(LowData);
            ReceiveAck();
            WriteByte(HighData);
            ReceiveAck();
            Stop();
            Delay(2000);
            }
            //******************************************************************************


            評論


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

            關閉