How to Writing / Reading the on-chip flash

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

How to Writing / Reading the on-chip flash

2,209 Views
victoryang
Contributor I

Hi,

I am using  LPC11u37 Xpresso board, My question is how to write a array of data into Flash memory and read the data from the Flash memory .Is there any API or any sample code available. Can anyone help me in this regards?

Thanks!

Labels (1)
0 Kudos
Reply
3 Replies

1,903 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Victor,

   Could you tell me, do you just want to define a array of data, like the constant data to the flash defined address? Or you still want to write and erase it?

   If you just want to define a constant data array, it's very easy, you just need to define it directly, but the detail method is different with the IDE.

Please tell me what the IDE you are using, now, take IAR as an example, if define the data in the defined address 0x1000, you can define it like this :

#pragma location = 0x1000
__root const char __DATA_config[] = {…}

If you are using MDK, you can use it like this:

const char __DATA_config[] __attribute__((at(0x1000))) ={…}

Buf if you want to write the flash and erase it, you refer to my attached application note.

Wish it helps you!

If you still have question about it, please kindly let me know.

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,903 Views
victoryang
Contributor I

Hi Kerry,

   Thanks for your reply! 

   I use Keil IDE and I just want to write some datas(such as an 64-bytes array) to the on-chip flash. Also I find some APIs as below, but i don't know how to do with that. 

  1. U8 wnDrv_Flash_PrepareSectors(U32 u32StartSector, U32 u32EndSector);
  2. U8 wnDrv_Flash_CopyRAMToFlash(U32 u32DstAddr, U32 u32SrcAddr, U32 u32Len);
  3. U8 wnDrv_Flash_EraseSectors(U32 u32StartSector, U32 u32EndSector);
  4. U8 wnDrv_Flash_ErasePage(U16 u16StartPage, U16 u16EndPage);

.....

   Can you give me some examples? Thanks.

0 Kudos
Reply

1,903 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Victor,

   Do you want to also to modify these 64-bytes array in your app code?

  If you don't want to  modify it, you can just define the constant code, you even don't need to define the specific flash address. But if you want to write these byte to the flash in your app code, you need to use the IAP code to write it.

About the according API usage, you totally can refer to application code which I give you, in that code, there has the samples for your reference.

Wish it helps you!

If you still have question about it, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply