AnsweredAssumed Answered

LPC1778: Problem using EEPROM and IAP calls in the same application

Question asked by Carsten Groen on Nov 10, 2016
Latest reply on Nov 10, 2016 by jeremyzhou

I have a problem with the combined use of IAP and EEPROM of the LPC1778.

Both works fine when used separately, but once I mix them, I get problems with the IAP interface.

 

I have narrowed it down quite a bit and think I know where the problem is, I just don't know how to avoid it...

 

First I do EEPROM_init and EEPROM_read.

After this I do IAP erase of a Flash sector. When the IAP command 0x52 (erase) is issued, I get a return value of 11 back (Flash interface busy).

I have narrowed it down to the EEPROM_Read function, I have included the EEPROM_read code here:

 

void EEPROM_Read(uint16_t page_offset, uint16_t page_address, void* data, EEPROM_Mode_Type mode, uint32_t count)
{
  uint32_t i;

     LPC_EEPROM->INT_CLR_STATUS = ((1 << EEPROM_ENDOF_RW)|(1 << EEPROM_ENDOF_PROG));
     LPC_EEPROM->ADDR = EEPROM_PAGE_ADRESS(page_address)|EEPROM_PAGE_OFFSET(page_offset);
  return; // IAP calls will work when returning here
     if(mode == MODE_8_BIT)
          LPC_EEPROM->CMD = EEPROM_CMD_8_BIT_READ|EEPROM_CMD_RDPREFETCH;
  return; // IAP calls will NOT work when returning here
.
.
.
.

 

If I return from the EEPROM_Read function in the first return in line 7, the following IAP commands works fine.

If I return from the read function at the second return (line 10) the IAP commands works fine afterwards.

So it seems that the LPC_EEPROM->CMD assignment in line 9 is the problem.

 

So, there must be some dependency between the EEPROM and IAP interfaces ?

And if so, is there a "magic" value I can send to the EEPROM CMD register to "release" it so the IAP functions will work afterwards ??

Outcomes