TI中文支持网
TI专业的中文技术问题搜集分享网站

6678 IIC 读写超时问题

  今天在实验6678 的IIC总线读写EEPROM的时候遇到一个有意思的问题。

     当我连接上仿真器在debug界面 无论怎么点击reset cpu 或者 reset system  或者是restart   EEPROM的读写都是正常的。但只有点击了停止仿真,在不断电的情况下,在连接进行仿真 就一直出现iic总线超时,不知是什么原因? 请高手指点一下,谢谢

程序中 I2C_write()I2C_read()均为  Keystone_I2C_init_drv.c 中定义函数

main

{

…………

I2C_Master_Init(400);

for(i=0; i<100; i++)
{
memset(IIC_Rcv_buf,0x30,256);
memset(IIC_Snd_buf,0x1+i,256);
/* fill with pattern */

I2C_EEPROM_block_write( I2C_address, address0, 256, &IIC_Snd_buf[0]);
I2C_EEPROM_read( I2C_address, address0 , 256, &IIC_Rcv_buf[0]);
printf("%x is receive \n", IIC_Rcv_buf[0]);

……

}

Uint32 I2C_EEPROM_block_write(Uint32 I2C_address, Uint32 data_address, Uint32 uiByteCount, Uint8 * ucBuffer)
{
Uint8 i2cBuffer[I2C_EEPROM_BLOCK_SIZE+4];

/*put data address into first two bytes of i2cBuffer,
and write it to I2C EEPROM*/
i2cBuffer[0]= data_address>>8;
i2cBuffer[1]= data_address;
memcpy(i2cBuffer+2, ucBuffer, uiByteCount);

uiByteCount= I2C_write(I2C_address, uiByteCount+2, i2cBuffer, I2C_WAIT);
if(uiByteCount>2)
{
uiByteCount-= 2;
//wait about 5ms for I2C EEPROM internal write complete
TSC_delay_ms(5);
}
else
uiByteCount=0;

return uiByteCount;
}

Uint32 I2C_EEPROM_read(Uint32 I2C_address, Uint32 data_address, Uint32 uiByteCount, Uint8 * ucBuffer)
{
Uint8 ucAddrBuffer[4];
Uint32 byteSuccess=0;
/*put data address into first two bytes of ucBuffer,
and write it to I2C EEPROM*/
ucAddrBuffer[0]= data_address>>8;
ucAddrBuffer[1]= data_address;

/*Dummy write, setup read address*/
byteSuccess= I2C_write(I2C_address, 2, ucAddrBuffer, I2C_WAIT);
if(2!=byteSuccess)
return 0;

//wait about 5ms for I2C EEPROM internal write complete
TSC_delay_ms(5);

/*read data*/
byteSuccess= I2C_read(I2C_address, uiByteCount, ucBuffer, I2C_WAIT);

return byteSuccess;
}

bomer:

你的eeprom有没有写保护。

lei zhang1:

回复 bomer:

用万用表看了一下,写保护信号一直是低

而且 在不好用的情况下 是SCL SDA信号没有反应  SCL一直是高

JY LI:

请问你的例程是哪里的?是PDK包里的吗

赞(0)
未经允许不得转载:TI中文支持网 » 6678 IIC 读写超时问题
分享到: 更多 (0)