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.

How to store data in flash

Other Parts Discussed in Thread: CONTROLSUITE, UNIFLASH

I want to know is there a way to store data in flash sector of F28063 ? 

I have seen the .cmd file,

I want to know how to save data in a sector of flash such that when the data is saved it should not be erased, when the program is been loaded.

some documents are available which are not compatible with the current F2806x microcontrollers in CCS v6.1. 

Hoping for reply :)

 

  • Gaurav,

    You can store data in a flash sector. You should reserve that sector just for your data (not your program). That way, if you re-flash the program, your data is not lost. The programming tools will all allow you to specify which sectors get erased when you are flashing the device.

    It is not clear if you're asking about runtime data or static manufacturing data (such as a serial number). Programming the flash at runtime requires use of the flash APIs. These can be found in ControlSuite for the F2806x family of devices. Flashing data at manufacturing time is no different than flashing your program. You can use whatever tool you are using to flash the device during manufacturing (e.g., Uniflash).

    Regards,
    David
  • Sir,

    Please can you tell me how to reserve a sector of flash for storing data in CCS 6.1.

    When I load the program in flash, I will be storing data once in a specific sector of flash which can be changed.

    How to store data in the allotted flash sector ?

    Is :
    Example_MemCopy(&Flash28_API_LoadStart, &Flash28_API_LoadEnd, &Flash28_API_RunStart);
    and in .cmd:
    Flash28_API: // Applicable only when API is not in BootROM
    {
    -lFlash2802x_API_V100a.lib(.text)
    } LOAD = FLASHD,
    RUN = PRAML0,
    LOAD_START(_Flash28_API_LoadStart),
    LOAD_END(_Flash28_API_LoadEnd),
    RUN_START(_Flash28_API_RunStart),
    PAGE = 0

    required for achieving the above task for TMS320F2806x ?

    Hoping for a reply :)

  • Gaurav,

    First, to be clear, where you put the flash APIs has nothing to do with where you put the data that is being stored in the flash.

    For the data, let's just suppose you plan to use flash sector 'x'.  Use a DATA_SECTION pragma to put the constants of interest into a named section.  Then, link that section to flash sector 'x'.  Do not link anything else to that sector except the flash data.  You can use multiple pragmas to put more than one constant into the section.  Like this:

    #pragma DATA_SECTION(x, "MyData");
    const int x[5]={1,2,3,4,5};

    #pragma DATA_SECTION(y, "MyData");
    const int y = 0x4545;

    #pragma DATA_SECTION(z, "MyData");
    const long z = 0x12345678;

    Then in the .cmd file:

       MyData            : > FLASH_x,        PAGE = 0

    Regards,

    David

  • Hi, David.

    Your answer is very helpful to me. I was looking for solution of this issue.

    I have a question about your comment.

    For storing consist data, I defined data as your comment.

    #pragma DATA_SECTION(x, "MyData");
    const int x[5]={1,2,3,4,5};

    #pragma DATA_SECTION(y, "MyData");
    const int y = 0x4545;

    #pragma DATA_SECTION(z, "MyData");
    const long z = 0x12345678;

    In cmd file.

     MyData              : > FLASHB,     PAGE = 1

    As a result, data was saved.

    But integer variable y has 2 words as bleow image.

    I don't understand why zero is stored.

    I know Integer type has 1 word (=16 bits) but y has 2 word and dummy 0.

  • Remony,

    I think all that is going on here is you have an unused memory location at address 0x3F0001. The linker assigned y to 0x3F0000. It then needs to align z on a long word boundary (all 32-bit words on C28x should be aligned to 32-bit word boundaries to allow for proper access), so it placed z at 0x3F0002. Hence, there is a hole at 0x3F0001. y itself is only 16 bits wide.

    Try allocating a y1 var right after y in your code:

    #pragma DATA_SECTION(y, "MyData");
    const int y = 0x4545;

    #pragma DATA_SECTION(y1, "MyData");
    const int y1 = 0x6767;

    My guess is y1 will end up at address 0x3F0001.

    Regards,
    David