I have problem here that after I read some data from EEPROM, my I2C device (a touch keypad) is causing the system to HardFault. If I don't read data on EEPROM, the I2C device works normally with the whole system having no problem. However, as soon as I perform reading on EEPROM, once I touch any key on the keypad (the I2C device), system goes to HardFault.
I tried to trace down where it goes to HardFault, it's when running this line of code in i2c_11u6x.c
iic->sXfer->slaveAddr |= iic->mXfer != 0;
The whole code block as follow:
/* I2C Slave event handler */
void Chip_I2C_SlaveStateHandler(I2C_ID_T id)
{
int ret;
struct i2c_interface *iic = &i2c[id];
/* Get the currently addressed slave */
if (!iic->sXfer) {
struct i2c_slave_interface *si2c;
I2C_SLAVE_ID sid = getSlaveIndex(iic->ip);
si2c = &i2c_slave[id][sid];
iic->sXfer = si2c->xfer;
iic->sEvent = si2c->event;
}
iic->sXfer->slaveAddr |= iic->mXfer != 0;
ret = handleSlaveXferState(iic->ip, iic->sXfer);
if (ret) {
if (iic->sXfer->status == I2C_STATUS_DONE) {
iic->sXfer = 0;
}
iic->sEvent(id, (I2C_EVENT_T) ret);
}
}

Can anyone tell me why this is happening? Is EEPROM and I2C related in any way? I don't understand why EEPROM is affecting I2C.