您现在的位置: 范文先生网 >> 理工论文 >> 电子通信论文 >> 正文

MAX517与单片机的I2C总线数据通信

时间:2007-1-20栏目:电子通信论文

SDA=1;

NOP;

}

//应答子函数

void Ack(void)

{

SDA=0;

NOP;

SCL=1;

NOP;

SCL=0;

}

//发送数据子程序,Data为要发送的数据

void Send(uchar Data)

{

uchar BitCounter=8; //位数控制

uchar temp; //中间变量控制

do{

temp=Data;

SCL=0;

NOP;

if((temp&0x80)==0x80)

//如果最高位是1

SDA=1;

else

SDA=0;

SCL=1;

temp=Data<<1; //左移

Data=temp;

BitCounter--;

}while(BitCounter);

SCL=0;

}

//读一个字节的数据,并返回该字节值

uchar Read(void)

{

uchar temp=0;

uchar temp1=0;

uchar BitCounter=8;

SDA=1;

do{

SCL=0;

NOP;

SCL=1;

NOP;

if(SDA) //如果SDA=1

temp=temp|0x01;

else

temp=temp&0xfe;

if(Bi

上一页  [1] [2] [3] [4] 下一页

下页更精彩:1 2 3 4 下一页

★相关文章: