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.
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); }
Hello Nir,
Our primary expert is out-of-office, so I will look into this and get back to you sometime tomorrow.
Best regards,
Omer Amir
Hi ,
Please try using the following code snippet for the Read data
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
I2C_putMasterData(I2C0_BASE, index * 4);
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2C_isMasterBusy(I2C0_BASE));
I2C_setSlaveAddress(I2C0_BASE, SLAVE_ADDRESS, I2C_MASTER_READ);
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
while(I2C_isMasterBusy(I2C0_BASE));
for(i=0;i<len;j++)
{
dest[i]=I2C_getMasterData(I2C0_BASE);
I2C_setMasterConfig(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
while(I2C_isMasterBusy(I2C0_BASE));
SysCtl_delay(1200);
}
Best Regards
Siddharth