LPC11xx runtime flash access

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

LPC11xx runtime flash access

450 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by corwinb on Mon Feb 18 14:41:51 MST 2013
I need to write and read some long term vars in flash during run-time.  I found AN10995 and associated code and can sort of see what is going on.  What I am looking for is an explanation of the commands and the proper sequence.  I am having trouble equating Chapter 26 (Flash programming firmware) in UM10398 to AN10995.

What am I missing?
Labels (1)
0 Kudos
2 Replies

406 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by corwinb on Wed Feb 20 10:24:25 MST 2013
I discovered 11008 - Flash based non-volatile storage.
This appnote/code illustrates exactly what I want to do. 

My first problem:
I was prepareSectors() before EraseSectors(), but not before CopyRAMToFlash().

Next problem:
I am not bootloading so bootloader example is not perfect template for me.  The bootloader example does not disable interrupts before IAP_EXECUTE_CMD() and then enable interupts after.  This did not prevent my simple test from working, but, in certain applications it could cause problems.

All works fine now.

0 Kudos

406 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by corwinb on Tue Feb 19 10:56:51 MST 2013
Got it.  I think.

Although I have not succeeded in my task I think I understand the basic concept.  u32IAP_CopyRAMToFlash fails with return code of 9 (IAP_STA_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION).  The args for the following func are as follows:
srcAddr = 0x10000050  (address of my ram structure)
destAddr = 0x7000
destSector = 7
byte_count = 256

target chip LPC1114

The Prepare and EraseSectors functions succeeded and I use the same sector for the Copy func so I don't understand what the problem is.  Unless sector 7 is off limits for some reason.  I did not find any hint of this in the docs.

I did start with the Bootloader example from AN10995 which uses the uart. 
I am not using a uart.  The u32IAP* funcs (unedited from example) I am using do not appear to be tailored to uart?

Any ideas?

//---------------------------------------------------------------------------------------------------
tU32 write_long_term_vars_to_flash( tU32 srcAddr, tU32 destAddr, tU32 destSector, tU32 byte_count )
{
if( u32IAP_PrepareSectors( destSector, destSector ) == IAP_STA_CMD_SUCCESS )
{
if( u32IAP_EraseSectors( destSector, destSector ) == IAP_STA_CMD_SUCCESS )
{
if( u32IAP_CopyRAMToFlash( destAddr, srcAddr, byte_count ) == IAP_STA_CMD_SUCCESS )
{
return 0;
}
}
}
return 1;
}
0 Kudos