Skip to main content
nanayakkaraan
Associate III
February 28, 2011
Question

Define an array in Flash

  • February 28, 2011
  • 16 replies
  • 3972 views
Posted on February 28, 2011 at 12:16

Define an array in Flash

    This topic has been closed for replies.

    16 replies

    Andrew Neil
    Super User
    May 17, 2011
    Posted on May 17, 2011 at 14:26

    (stupid forum - spurious post)

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    trevor23
    Associate III
    May 17, 2011
    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

    Andrew Neil
    Super User
    May 17, 2011
    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.

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    nanayakkaraan
    Associate III
    May 17, 2011
    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.

    nanayakkaraan
    Associate III
    May 17, 2011
    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 :)

    trevor23
    Associate III
    May 17, 2011
    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).