lpcware

LPC1549 EEPROM update time

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by EtaPhi on Thu Feb 12 07:44:29 MST 2015
Hello,
I want to implement "persistent" variables which keep their value even if power is switched off.
The C language doesn't define this kind of variables, but it's easy to add their management.
The macro persistent extends C syntax as follows:

#define persistent __attribute__ ((section(".nvram")))


A persistent variable definition becomes:

persistent unsigned int SomeVariable = 1
;

When the C compiler processes this definition, it reserves four bytes in the "nvram" section and saves SomeVariable initial value so that the startup code can initialize it.
The persistent macro can also used with other storage attributes, such as "volatile", "const", "static", "register" etc. For istance,

persistent volatile int Variable = 2;


is a valid statement (it also explains why the macro name isn't "nonvolatile")

The "nvram" section size is fixed.
"nvram" size should be a multiple of 64 bytes which is LPC15xx EEPROM page size.
It must also be smaller than 1984 bytes because the upper 64 bytes of EEPROM are reserved and because EEPROM must store two copies: the startup one and the shutdown one.

The startup code use a copy to restore the previous values, while the BOD (Brown Out Detector) interrupt updates the shutdown copy.
Some precautions must be taken to recognize a valid startup copy, but they don't matter for this post, which deals with the shutdown copy update.

It seems that only the ROM API can write or read LPC15xx EEPROM, even if it's mapped from 0x0320000 to 0x03200FFF and it's connected to AHB Matrix.
Perhaps LPC15xx EEPROM can't be read or written at AHB maximum speed, so AHB must be slowed to 12 MHz or less by using SYSAHBCLKDIV register.
This isn't a issue for BOD interrupt handler, because LPC1549 is "dying" when it's executed and no other code must run.

The time it takes to erase some pages and to update their data is the issue!

LPC15xx Datasheet says that it typically takes 2.9 ms to write 64 bytes.
It doesn't say if EEPROM update time increases linearly as the number of 64 bytes to write.
It doesn't say if a previous bulk erase may shorten update time.
UM10736 doesn't explain EEPROM CTRL registers and it doesn't say if it's possible to access EEPROM data without ROM API.

I need these infos to check if the bulk capacitor has enough energy to finish EEPROM update in the WORST CASE.

Is here someone who can help me?

EtaPhi

Outcomes