LPC11u68 HardFault after using I2C connected device with EEPROM reading data

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC11u68 HardFault after using I2C connected device with EEPROM reading data

797 Views
leechen
Contributor III

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);
   }
}

Screen Shot 2018-04-26 at 9.51.52 AM.png

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.

1 Reply

629 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  Lee Chen,

   Please check this description from the user manual:

27.7.1.7 Interrupts during IAP
The on-chip flash memory and EEPORM are not accessible during erase/write
operations. When the user application code starts executing, the interrupt vectors from the
user flash area are active. Before making any IAP call, either disable the interrupts or
ensure that the user interrupt vectors are active in RAM and that the interrupt handlers
reside in RAM. The IAP code does not use or disable interrupts.

So, when you read the internal eeprom, you will call IAP functions, you need to disable the interrupts, or relocate your interrupt vectors in RAM.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------