Using the LPC2124 Program Flash for variable storage?

The data sheet for the LPC2124 says: “The application program may also erase and/or program the flash while the application is running.”

I was wondering if any of you have used the internal FLash for your own use for storing data.

If so, can you offer any information on how one goes about doing this ?

Thanks

when you erase/write the flash you must run your code from RAM, this makes your job somehow tricky i.e. you must copy your flash write routines in RAM and execute them from there.

you can look how Rowley and IAR made their flash loaders, the sources are distributed in their packages

Thanks

Tsvetan

Thanks, but maybe i was not clear.

i dont want to re-program the whole flash like an update. i just want to store a few user variables.

I posted a question almost exactly like this a few months ago. Jim Lynch went through the entire setup of how to get it working, although I ended up going with an external EEPROM. You might give it a quick search and if you can’t find it, I’ll take a look.

Thanks, i will do more searching.

http://www.sparkfun.com/cgi-bin/phpbb/v … highlight=

Below is the code I use to write and erase flash areas. Below is setup of IAP call then usage .This should get you started .

Good luck

/*------------------------------------------------------------------------

Module: C:\Tools\Code\PForth\csrc\LPC21IAP.c

Author: Tom

Project:

State:

Creation Date:

Description: In-Application (IAP) programming is the

performing of erase and write operations on

the

on-chip Flash memory as directed by the

end-user application code. The Flash boot

loader provides the interface for programming

the Flash memory. For detailed information

on the In-Application Programming please refer

to the Flash Memory System and

Programming chapter in the ARM LPC device User

Manual. In this application note, code

samples are provided in C and assembly, which

show how IAP may be used. The IAP

routine resides at 0x7FFFFFF0 and is Thumb

code.

------------------------------------------------------------------------*/

// -mthumb-interwork must set compiler option

#define rm_init_entry 0x7fffff90

#define rm_undef_handler 0x7fffffa0

#define rm_prefetchabort_handler 0x7fffffb0

#define rm_dataabort_handler 0x7fffffc0

#define rm_irqhandler 0x7fffffd0

#define rm_irqhandler2 0x7fffffe0

#define iap_start 0x7ffffff1 // for thumb mode set bit 0 to 1

#define iap_PrepSector 50

#define iap_CopyRamFlash 51

#define iap_erase 52

#define iap_blankCheck 53

#define iap_PartId 54

#define iap_Compare 56

#define iap_ReinvokeISP 57

typedef void (*IAP)(unsigned int ,unsigned int);

IAP iap_entry;

/ ***** EXAMPLE OF USAGE ******

case ID_IAP:

while(uart1TxEmpty()==0); // wait to clear all data in s

VICIntEnClr=0xFFFFFFFF;

VICSoftIntClr=0xFFFFFFFF;

PLLCON=0; // disable pll

PLLFEED=0xAA;

PLLFEED=0x55;

VPBDIV=0; // default back to 1/4 speed of system

iap_entry=(IAP) iap_start;

Scratch=M_POP;

iap_entry((unsigned int *)TOS,(unsigned int *)Scratch);

M_DROP;

initIO();

endcase;