This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
用逻辑分析仪看了时序图,没有错误,并且从机发回了数据,但是数据却传不回来,发现移位循环里P1IN&BIT7只能判断0不能判断1,请问是怎么回事?
您好,这是我的时序图,我的写地址是0xD0,读地址是0XD1,可以看出后面从机是有数据传出来的。我的读代码是
unsigned char DS_Read(void)
{
unsigned int temp;
unsigned int data=0;
//DS_SDA_H;
DS_SDA_IN;
DS_SDA_IN_H;
for(temp=0x80;temp!=0;temp>>=1)
{
DS_SCL_H; //SCL拉高
Delay_us(10);
if(DS_SDA_BIT==1)
{
data|=temp; //高电平保留
}
else
{
data&=~temp;
}
DS_SCL_L; //SCL拉低
Delay_us(10);
}
return data;
}
这个函数返回值一直是0,我的iic上拉电阻是4.7K,请问哪个方面会出现这个问题?