LPC18xx EEPROM

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

LPC18xx EEPROM

867 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by namorada on Thu Jun 04 00:30:56 MST 2015
Hi,

Im looking for a simple way to use the internal EEPROM of a LPC18xx.
Does anyone of you have a simple example on how to read and write in it?

Thanks you.
Labels (1)
0 Kudos
5 Replies

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Jun 04 09:36:37 MST 2015
Have you tried debugging? What is the address of the HardFault? What is the cause of the HardFault? Have you checked the value of EEPROM_ADDRESS?
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by namorada on Thu Jun 04 09:09:36 MST 2015
Indeed, i have already checked that fast, for sure...
I'm using a LPC1837...

What i really really don't understand is that my code is extract from there : HERE

I also tried to copy/paste the whole thing.. Same result...
It make me a HardFault on line 151... Any idea?
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Thu Jun 04 08:59:41 MST 2015
UM:


Quote:
2.3.4 On-chip EEPROM
The [color=#f00]LPC185x/3x parts[/color] with flash also include a 16 kB EEPROM. The EEPROM is divided into 128 pages. The last EEPROM page is protected.

0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Jun 04 08:53:38 MST 2015
Which LPC18xx are you using? I'm not sure all the member of the family have an EEPROM, and therefore will not have a function in the ROM for you to call, which might explain the HardFault.
0 Kudos

621 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by namorada on Thu Jun 04 07:55:46 MST 2015
I tried several example... No succes...

For the init:
LPC_EEPROM->CLKDIV = 1500 / (EEPROM_CLOCK_DIV-1); // 31 ; //EEPROM clock=1500 KHz
LPC_EEPROM->RWSTATE = (1500 / 28571429 + 1) | ((1500 / 14285714 + 1) << 8); //(0x3 | 0x5<<8); // Read waitstates.
LPC_EEPROM->WSTATE = ((1500 / 50000000 + 1) << 16) | ((1500 / 25000000 + 1) << 8) | (1500 / 100000000 + 1); // (0x2 | 0x3<<8 | 0x2<<16); //EEPROM wait state register
LPC_EEPROM->AUTOPROG = EEPROM_AUTOPROG_AFT_1WORDWRITTEN;//01 = erase/program cycle is triggered after 1 word is written


In the main:
EEPROM_Read(0,0,uint32_t_Buffer,4);
uint32_t_Buffer[0] = 0xAA;
uint32_t_Buffer[1] = 0xBB;
uint32_t_Buffer[2] = 0xCC;
uint32_t_Buffer[3] = 0xDD;
uint32_t_Buffer[4] = 0xEE;
uint32_t_Buffer[5] = 0xFF;
uint32_t_Buffer[6] = 0x87;
EEPROM_Write(0,0,uint32_t_Buffer,4);
uint32_t_Buffer[0] = 0x00;
uint32_t_Buffer[1] = 0x00;
uint32_t_Buffer[2] = 0x00;
uint32_t_Buffer[3] = 0x00;
uint32_t_Buffer[4] = 0x00;
uint32_t_Buffer[5] = 0x00;
uint32_t_Buffer[6] = 0x00;
EEPROM_Read(0,0,uint32_t_Buffer,4);


Fonctions definitions:
void EEPROM_Read(uint32_t pageOffset, uint32_t pageAddr, uint32_t* ptr, uint32_t size)
{
uint32_t i = 0;
uint32_t *pEepromMem = (uint32_t*)EEPROM_ADDRESS(pageAddr,pageOffset);
for(i = 0; i < size/4; i++)
{

ptr = pEepromMem;
}
}



void EEPROM_Write(uint32_t pageOffset, uint32_t pageAddr, uint32_t* ptr, uint32_t size)
{
uint32_t i = 0;
uint32_t *pEepromMem = (uint32_t*)EEPROM_ADDRESS(pageAddr,pageOffset);

if(size > EEPROM_PAGE_SIZE - pageOffset)
{
size = EEPROM_PAGE_SIZE - pageOffset;
}

for(i = 0; i < size/4; i++)
{
pEepromMem = ptr;
}
}



Each call to the Read function give me a HardFault..

I also tried via the IAP finctions, but it always return me : IAP_INVALID_COMMAND...

Me? Desperate? Yes.. in a way ...
0 Kudos