如何让X9241正常响应。
我用I2C总线可以让24c16正常响应,但是不能让x9241正常响应。不知何故。望各位大侠不吝赐教。
我是这样发送字节和等待应答的(附程序):
void SendByte(uchar c)
{
uchar BitCnt;
//the length of data to be send is 8 bits
for(BitCnt=0;BitCnt <8;BitCnt++)
{
if(c&0x80)
{
SDA=1; //judge the sending bit
}
else
{
SDA=0;
}
_Nop();
SCL=1; //Set clock, and notice the device to receive
_Nop();
_Nop(); //Be sure the clock holding time > 4,7us
_Nop();
SCL=0;
c = c < < 1;
}
_Nop();
_Nop();
SDA=1; //The sending action is over
_Nop(); //and release the data line
_Nop();
SCL=1;
_Nop();
_Nop();
_Nop();
ack = !SDA; //judge whether the ack bit is received
SCL=0;
_Nop();
_Nop();
}
发表时间:2004年4月15日17:18:30