This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Data arrays in flash



I've successfully executed the example flash project, so I know how to link code into flash.  What I would like to try, is running a project with the code in ram, but using flash to store a couple of float arrays.  I have created my own section in flash in the linker, and used the data section pragma to put the array there.  But when I run the program the debugger shows NAN for all of the values of the array.  I have the init_flash() function before I use the array, is there something else that needs to be done?  Thanks in advanced!

  • hello kingmj,

    You have to think how you initialize your array - in your case the array is obviously initialized during runtime, for example:

    float myArray[10] = {0, 1.1, 2.2, 3.3, 4.4 ,5.5, 6.6, 7.7, 8.8, 9.9};

    since you placed myArray into a FLASH section, you must init the array using flash algorithms. Most likely this is not what you are looking for, since you'd like to have your array ready @ boot time. So you either need to init your array @ load time see "Assembly language tools User guide", section "Initialization of variables at load time" (not shure if this works for data linked to flash) or you program your array seperatly from your code into the flash in a second programming step. Hope this helps.

    Best regards

    Andreas