AN11008 Flash based non-volatile storage?

27 Feb 2015

I'm used to using PIC series microcontrollers with a typically 256 byte NVRAM block, basically high-endurance EEPROM.

The LPC devices do not appear to have an equivalent, but NXP AN11008 seems to describe a way to do this. Has anyone else tried importing it, or coded their own system?

Otherwise I should probably just fit an I2C EEPROM for configuration.

27 Feb 2015

There is a generic flash write library for LPCs, but not something like this which increases flash lifespan. The question would be how often you have to write new data. Is is not often? Just use flash directly. Reasonably often? Implement something like this. Very often? Use an external IC.

27 Feb 2015

I didn't even know there was a flash library on here until I saw your post. I only found it by looking for "IAP". Now I know about it I can see if it'll do what I want. Also the LPC11UXX would appear to have EEPROM read and write IAP commands? I'm actually interested in the LPC1114 right now.

I get the impression there's a syntax for reserving the flash blocks so they don't get used for code?

Or do we just use the top blocks and assume the code won't grow that far?

27 Feb 2015

The NXP IAP library has that built in, at line 36 here: http://developer.mbed.org/users/okano/code/IAP/file/cee1a2a734c9/IAP.cpp. Although IIRC there was something wrong with either exact location or the syntax, but that did not affect that it reserved flash fine (Could be something like that it was added to SRAM consumption in the compiler details, but not actually in the program).

At the same time I got a Freescale IAP library, and there my idea is to simply use indeed top block of flash since indeed if you take care a bit code simply won't come there.

28 Feb 2015

I couldn't make sense of that line at first until I realised it used things that were defined in the ".h" file, Having read the header a bit it is clearer.

I'm curious as to what the preceding two #define directives actually do though as they appear to be "nested".

Also would I need to disable interrupts or does that happen automatically? I'm not certain they'll be enabled in the first place but MBED has some "timer tick" functions that must use a timer, so I'm fairly sure there'll be at least one interrupt by default.

I think I read somewhere that interrupts had to be disabled for IAP unless you could copy your interrupt handler to RAM, so presumably the entire flash memory becomes inaccessible during programming. I might have misunderstood that bit? Somewhere else I read that interrupts had to be disabled before calling any IAP function as the entry code wasn't safe for interrupts.

28 Feb 2015

No idea why he does that define exactly that way, might be a leftover from some attempts, or it might be required.

IIRC calls ROM functions which might automatically disable interrupts, but not sure about it. In general I would make sure you have no active interrupts. While if you use wait/ticker functions a timer is always running, the interrupt on your devices is only enabled if you got an active ticker object. (Some devices have less than 32-bit resolution on their timer, so they do have an interrupt running to add some software bits to make it 32-bit, but thats not the case for you).