EmbeddedRelated.com
Forums

LPC2368 Flash as Data Memory

Started by mave...@mighty.co.za February 4, 2008
I have a question I have a project whereby I wish to use the Flash memory as data memory. And YES the LCP have only 10 000 write cycles and YES it has a slow responce and YES, YES, YES. I have seen all the postings regarding external flash and eeprom and NVRAM and that is quite nice but my project calls for this setup.

I have looked at IAP and I have tried to search for other code samples but I can not see a definate sample code / application note of how to use this and maybe use it as byte accessable data space. Thus my question is did someone tried and used it that might lead me to the correct path or have some sample lib's to share?

Regards

An Engineer's Guide to the LPC2100 Series

Hi,
I have seen something similar explained once, but I can't remember - I think
it was an application note from Freescale related to MC9S12
microcontrollers -
depending the amount of data needed to be saved and the rate of
savings, you
may write in a number of blocks what you need; reserve a number of -say
-10 blocks ;
write a block when you need; after writting the last one, erase the
first and write there;
this way the number of write cycles will be 100,000 times !
The most important thing is the rate of savings - if your application
writes/saves
the data too often, it is wise to use an eeprom, the write cycles are
guaranteed
to be one million.
Regards,
Ioan

m...@mighty.co.za wrote:
>
> I have a question I have a project whereby I wish to use the Flash
> memory as data memory. And YES the LCP have only 10 000 write cycles
> and YES it has a slow responce and YES, YES, YES. I have seen all the
> postings regarding external flash and eeprom and NVRAM and that is
> quite nice but my project calls for this setup.
>
> I have looked at IAP and I have tried to search for other code samples
> but I can not see a definate sample code / application note of how to
> use this and maybe use it as byte accessable data space. Thus my
> question is did someone tried and used it that might lead me to the
> correct path or have some sample lib's to share?
>
> Regards
>
>
>I have a question I have a project whereby I wish to use the Flash memory
>as data memory. And YES the LCP have only >10 000 write cycles and YES it
>has a slow responce and YES, YES, YES. I have seen

and YES, it might corrupt flash memory and make the board dead,
and YES a simple mistake in software might write 10000 cycles in 50 sec.

Warm Regards,

Mukund Deshmukh,
Beta Computronics Pvt Ltd.
10/1 IT Park, Parsodi,
Nagpur -440022 India.
Web site - http://betacomp.com

MEET US AT,

Chinaplas 2008, Shanghai, China.
--- In l..., maveric@... wrote:
>
> I have a question I have a project whereby I wish to use the Flash
memory as data memory. And YES the LCP have only 10 000 write cycles
and YES it has a slow responce and YES, YES, YES. I have seen all the
postings regarding external flash and eeprom and NVRAM and that is
quite nice but my project calls for this setup.
>
> I have looked at IAP and I have tried to search for other code
samples but I can not see a definite sample code / application note of
how to use this and maybe use it as byte accessible data space. Thus
my question is did someone tried and used it that might lead me to the
correct path or have some sample lib's to share?
>
> Regards
>
Hi,

you know about the risks and the shortcomings, thats OK. What you are
looking for is in the files section. Search for this:

EE_demo_1_1.zip
LPC2000 onchip Flash as EEPROM demo, rev. 1.1

Just checked the Data Sheet and in section 7.2 it says min 100k cycles
+ 20 years retention.
That should be just fine for many applications that require EEPROM
functionality.

Cheers, Bob
WHy not using some NVRAM, like FRAM for example, just extend your RAM
area, or use SPI.

I don't know how much space you need of course, if it's only around
64KB, then this is still low cost. If you want more it becomes much
more expensive.
Hi,
I have recently used IAP in my application .You can try this code it will
definitely work, as it is working in my application. Please remeber one
thing during using of IAP PLL and other interrupts will be disabled.

I am adding the code bellow:

typedef void (*IAP)(unsigned int [],unsigned int []);
IAP iap_bypointer;
void iap_byfunction (unsigned *cmd,unsigned *rslt,unsigned entry);
unsigned command[5];
unsigned result[5];
unsigned int *Ram_Pointer;
unsigned int Ram_Arry[5]={0,1,2,3,4};

void myfunction(void)__arm
{
unsigned char index;
//unsigned char i;
unsigned int save_VicInt;

IOSET1|=0x02000000;
save_VicInt = VICIntEnable; // save interrupt enable status
VICIntEnClr = 0xFFFFFFFF; // disable all interrupts
//********************** PLL stop *************************//
PLL0CON=0x00;
PLL0CFG = 0x20;
PLL0FEED=0xAA;
PLL0FEED=0x55;
while(PLL0STAT & 0x0400);
PLL0CON=0x00;
PLL0CFG = 0x20;
PLL0FEED=0xAA;
PLL0FEED=0x55;

//**************************************************************//

iap_bypointer = (IAP) 0x7FFFFFF1; //set IAP entry address in function
pointer

Ram_Pointer = 0x40000100; //Set pointer to RAM
for (index = 0; index<0x07; index++) //Copy data to be written to flash
into the RAM
{
*Ram_Pointer = Ram_Arry[index];
Ram_Pointer++;
}

command[0] = 0x36; //command code for "Read part ID"
iap_byfunction(command,result,0x7FFFFFF0); //Call IAP functions by function
method
command[0] = 50; //Prepare sector five for a write operayion
command[1] = 5;
command[2] = 5;
iap_bypointer(command,result);

command[0] = 52; //erase sector five
command[1] = 5;
command[2] = 5;
command[3] = 12000; //Cclk == 12Mhz Pll is disabled in startup code
iap_bypointer(command,result);

command[0] = 50; //Prepare sector five for a write operayion
command[1] = 5;
command[2] = 5;
iap_bypointer(command,result);

command[0] = 51; //write 512 bytes from address 0x40000100
command[1] = 0x00005000; //to 0x00005000 in flash memory;
command[2] = 0x40000100;
command[3] = 512;
command[4] = 12000; // see erase comment above
iap_byfunction(command,result,0x7FFFFFF0);

//********************** PLL Start ******************************//
PLL0CON|=0x01;
PLL0CFG =0x24;
PLL0FEED=0xAA;
PLL0FEED=0x55;
while(PLL0STAT & 0x0400);
PLL0CON|=0x02;
PLL0CFG =0x24;
PLL0FEED=0xAA;
PLL0FEED=0x55;
//********************************************************************//
VICIntEnable = save_VicInt;
IOCLR1 |= 0x02000000;
}

void iap_byfunction (unsigned *cmd,unsigned *rslt,unsigned entry)
__thumb //compile this in Thumb instruction

{
__asm { mov r15,r2; } //move entry address into PC

}
On 2/4/08, Petrescu wrote:
>
> Hi,
> I have seen something similar explained once, but I can't remember - I
> think
> it was an application note from Freescale related to MC9S12
> microcontrollers -
> depending the amount of data needed to be saved and the rate of
> savings, you
> may write in a number of blocks what you need; reserve a number of -say
> -10 blocks ;
> write a block when you need; after writting the last one, erase the
> first and write there;
> this way the number of write cycles will be 100,000 times !
> The most important thing is the rate of savings - if your application
> writes/saves
> the data too often, it is wise to use an eeprom, the write cycles are
> guaranteed
> to be one million.
> Regards,
> Ioan
>
> m...@mighty.co.za wrote:
> >
> > I have a question I have a project whereby I wish to use the Flash
> > memory as data memory. And YES the LCP have only 10 000 write cycles
> > and YES it has a slow responce and YES, YES, YES. I have seen all the
> > postings regarding external flash and eeprom and NVRAM and that is
> > quite nice but my project calls for this setup.
> >
> > I have looked at IAP and I have tried to search for other code samples
> > but I can not see a definate sample code / application note of how to
> > use this and maybe use it as byte accessable data space. Thus my
> > question is did someone tried and used it that might lead me to the
> > correct path or have some sample lib's to share?
> >
> > Regards
> >
> >