Part Number: TMS320F28386S
Hello,
I have a M24C08 I2C EEPROM, connected to the CM.
I am able to write and read data from the EEPROM.
However, the EEPROM expects a NACK from the master when done reading a block of data.
I couldn't fined how to generate the NACK condition for the EEPROM.
Also, there is no Stop condition generated.
The result is that after reading data, the SDA line stays low, and the CLK line is high.
and the I2C bus is stuck.
Can you please explain how to properly read a block section, to have a Stop condition generate, and also to be able to send a NACK to the EEPROM?
void m24c08_Read_Data(uint8_t index, uint8_t * dest, uint32_t len)
{
uint16_t i;
// Read Byte - Select address.
I2C_setSlaveAddress(I2C0_BASE,M24C08_ADDRESS,I2C_MASTER_WRITE);
I2C_putMasterData(I2C0_BASE, index * 4);
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);
// Send restart.
SysCtl_delay(2400);
// Send Read command
I2C_setSlaveAddress(I2C0_BASE,M24C08_ADDRESS,I2C_MASTER_READ);
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
SysCtl_delay(1200);
for(i=0; i < len; i++) {
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
SysCtl_delay(1200);
dest[i] = I2C_getMasterData(I2C0_BASE);
}
// I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP);
}