cancel
Showing results for 
Search instead for 
Did you mean: 

Define an array in Flash

nanayakkaraan
Associate II
Posted on February 28, 2011 at 12:16

Define an array in Flash

16 REPLIES 16
Posted on May 17, 2011 at 14:26

(stupid forum - spurious post)

greg_t
Associate II
Posted on May 17, 2011 at 14:26

Any var is just a pointer to memory

Array in RAM is a pointer

If pointer points to flash memory address  -  the compiler will not create the ASM code that writes to flash

Posted on May 17, 2011 at 14:26

You are missing the point:

The question was how to locate an array into flash; ie, how to store the content in flash.

You can't do that just by setting a pointer.

trevor23
Associate III
Posted on May 17, 2011 at 14:26

@ANN can you specify your requirements in more detail? Are the array contents defined at compile time (const) or do you wish to change the array contents at run time? How big is the array, how big is your code, which device will you be using? Is it possible for reset or power down to occur while changing the array? If so can you live with the array being lost -- if not you will need to keep copies of flash pages before erasing pages and be able to detect and fix broken array at start up.

As you can see there are a lot of unknowns so you need to provide the detail

nanayakkaraan
Associate II
Posted on May 17, 2011 at 14:26

Agree with Andrew.

In IAR and STM32L combination, when the array ws defined with const key word it was placed in RAM.

Thanks for replies even though I am wondering how to do that :)

nanayakkaraan
Associate II
Posted on May 17, 2011 at 14:26

Array content need not to be changed at the run time from the defined values. So i would like to keep them in flash not in RAM.

I am using STM32L and IAR combination.

trevor23
Associate III
Posted on May 17, 2011 at 14:26

Can you post the code or maybe even the whole project as if the array is of significant size and is const (and not ''volatile'' or ''fast'' etc.) it should really end up in flash not RAM. What Andrew said is that const does not always force const variables to flash but in this case it should allow the compiler to do so unless I don't understand what you are trying to do (hence why you should post the code).