Flash memory Read and Write

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

Flash memory Read and Write

1,293 Views
ahmed007
Contributor II

Hello, 

I am using LPCXpresso55S16 and I want to dynamically allocate memory from the flash, write data to it, read from it, and free it when I need. Is there a tutorial or can anyone help me with that?

Best regard.

 

0 Kudos
Reply
2 Replies

1,081 Views
ED8500
Contributor I

Reads like a bad idea, though it might be possible you will bump into the max write cycles a flash can bear. Indeed, first copy your code to ram before erasing and writing flash memory.

BTW, page 2 of the datasheet says: "Up to 640 KB on-chip flash program memory with flash accelerator and 512 byte
page erase and write."

HTH

0 Kudos
Reply

1,278 Views
scottm
Senior Contributor II

Can you explain exactly what you mean by "dynamically allocate memory from the flash"? If you're talking about using it with something like malloc() and free(), it's not so simple. I'm not saying it can't be done, but it's more involved.

I actually came here to ask a question about the LPC55S69's flash API today since the documentation is pretty bad. On the S69, you can't erase or program flash above 100 MHz. I'm not sure about the S16's specs. You also can't program flash while running from flash, so you've got to either have a ROM bootloader like the S69 or you have to copy your code into RAM first.

Flash data can only be written and erased in chunks, probably 512 bytes but again the docs suck. Flash can only endure so many erase/write cycles, usually around 100,000 so you can't just use it constantly in normal operation. And the erase operations are slow, so you're interrupting the code execution to be able to erase and write new data.

With all of that in mind, there's a FLASHIAP example in the SDK that shows the basics of how to use the driver.

Scott

0 Kudos
Reply