Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] memory allocation..

2004-07-13 by Robert Adsett

At 04:32 AM 7/13/04 -0700, you wrote:
>Option1)
>Set the heap address in the linker file.

That won't work for using malloc to store data in flash

>
>Option2)
>Write your own malloc/free functions. Pass them an array address which can 
>be placed anywhere in the unused memory area.

This might.  To store data in flash using malloc/free you not only would 
have to write your own malloc & free but ensure (somehow) that you never 
wrote to the flash except through a routine that programmed the flash using 
the IAP facilities.  You would also need to keep track of three kinds of 
buffers in use, not in use but programmed, not in use and available. You 
would need to add logic to clean up the flash area if the micro was reset 
or powered of with the memory structures in an inconsistant state and do 
appropriate moving of data when you had to erase sectors etc...  Also 
writing would take considerably longer than reading.

Using flash to store data really has more in common with a file system than 
malloc/free.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.