Internal EEPROM access

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

Internal EEPROM access

1,124 Views
mail_stephen201
Contributor I

I'm looking for code examples for internal EEPROM access for the LPC4337 and there is next to nothing out there.

Appreciate any feedback however trivial.

It's a great micro, but support seems limited.

Labels (1)
0 Kudos
Reply
1 Reply

1,113 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Stephen,

Pls download the LPC open package from the link:

https://www.nxp.com/design/microcontrollers-developer-resources/lpcopen-libraries-and-examples/lpcop...

 

There is eeprom example code in the directory:

C:\DriveE\LPCOpenDirectory\Keil_IAR\LPC4337\LPC43xx_18xx\examples_43xx_18xx\periph_eeprom\src

 

I just copy part of the code from eeprom.c

/* Read data from EEPROM */
/* size must be multiple of 4 bytes */
STATIC 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[i] = pEepromMem[i];
}
}

/* Erase a page in EEPROM */
STATIC void EEPROM_Erase(uint32_t pageAddr)
{
uint32_t i = 0;
uint32_t *pEepromMem = (uint32_t*)EEPROM_ADDRESS(pageAddr,0);
for(i = 0; i < EEPROM_PAGE_SIZE/4; i++) {
pEepromMem[i] = 0;
#if AUTOPROG_ON
Chip_EEPROM_WaitForIntStatus(LPC_EEPROM, EEPROM_INT_ENDOFPROG);
#endif
}
#if (AUTOPROG_ON == 0)
Chip_EEPROM_EraseProgramPage(LPC_EEPROM);
#endif
}

/* Write data to a page in EEPROM */
/* size must be multiple of 4 bytes */
STATIC 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[i] = ptr[i];
#if AUTOPROG_ON
Chip_EEPROM_WaitForIntStatus(LPC_EEPROM, EEPROM_INT_ENDOFPROG);
#endif
}

#if (AUTOPROG_ON == 0)
Chip_EEPROM_EraseProgramPage(LPC_EEPROM);
#endif
}

for lpc43xx, there are 16KB EEPROM, which consists of 128 pages, each pages includes 128 bytes(32 words)

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply