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.

LAUNCHXL-F28377S: How to change the variables declared in flash during code execution?

Part Number: LAUNCHXL-F28377S
Other Parts Discussed in Thread: C2000WARE

I have a requirement of storing big size arrays of ADC results Uint16 type each of more than 2000 pts hence need to place in the flash memory (also there is requirement in application to retain this data after power off).

I am using DATA_SECTION pragma to define these arrays like this:

// Defines
//
#define RESULTS_BUFFER_SIZE 2000 //buffer for storing conversion results
//(size must be multiple of 16)

//
// Globals
//

Uint16 AdcaResults1[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults2[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults3[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults4[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults5[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults6[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults7[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults8[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults9[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults10[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults11[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults12[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults13[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults14[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults15[RESULTS_BUFFER_SIZE];
Uint16 AdcaResults16[RESULTS_BUFFER_SIZE];

Uint16 AdcaResultsFinal[RESULTS_BUFFER_SIZE];


Uint16 resultsIndex;

#pragma DATA_SECTION(AdcaResults1, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults2, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults3, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults4, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults5, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults6, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults7, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults8, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults9, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults10, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults11, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults12, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults13, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults14, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults15, ".AdcResultsFLASH");
#pragma DATA_SECTION(AdcaResults16, ".AdcResultsFLASH");

#pragma DATA_SECTION(AdcaResultsFinal, ".AdcResultsFanalFLASH");

Then Modified linker command file like this:

MEMORY
{
PAGE 0 : /* Program Memory */
...

...

...

/* Flash sectors */
FLASHA : origin = 0x080002, length = 0x001FFE /* on-chip Flash */
FLASHB : origin = 0x082000, length = 0x002000 /* on-chip Flash */
FLASHC : origin = 0x084000, length = 0x002000 /* on-chip Flash */
FLASHD : origin = 0x086000, length = 0x002000 /* on-chip Flash */
FLASHE : origin = 0x088000, length = 0x008000 /* on-chip Flash */
FLASHF : origin = 0x090000, length = 0x008000 /* on-chip Flash */
FLASHG : origin = 0x098000, length = 0x008000 /* on-chip Flash */
FLASHHI : origin = 0x0A0000, length = 0x010000 /* on-chip Flash */
// FLASHI : origin = 0x0A8000, length = 0x008000 /* on-chip Flash */
FLASHJ : origin = 0x0B0000, length = 0x008000 /* on-chip Flash */
FLASHK : origin = 0x0B8000, length = 0x002000 /* on-chip Flash */
FLASHL : origin = 0x0BA000, length = 0x002000 /* on-chip Flash */
FLASHM : origin = 0x0BC000, length = 0x002000 /* on-chip Flash */
FLASHN : origin = 0x0BE000, length = 0x002000 /* on-chip Flash */

PAGE 1 : /* Data Memory */

....

}

SECTIONS
{
......

//Adc results
.AdcResultsFLASH : > FLASHHI, PAGE = 0
.AdcResultsFanalFLASH : > FLASHL, PAGE = 0
.AdcResultsPristineFLASH : > FLASHK, PAGE= 0

......

}

After this program is flashed into flash memory. But the program cant be able to change values of arrays at run time (during execution). i.e. it cant modify the default values of each variable (which is 65535  probably the default value of undefined Uint16).

I dont understand why code cant modify the values stored in the flash memory?

Please suggest me changes in the code so that I can modify variables stored in flash during runtime (code execution) along with it should retain its values after power off.

Thank You 

Mandar Kothavade