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.

CCS/TMS320F28377D: How to read and write data to the MCU internal Flash

Part Number: TMS320F28377D
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

Hi 

i need to handle a counter in the FLASH, so every power off and on the current number would not lost.

is there any addresses avalible in the Flash? if yes, how do i access them?

Thanks!

  • Shimon,

    TMS320F28377D has 512KB of Flash per CPU.  Please check Table 6.3.2 Flash Memory Map in datasheet at

    http://www.ti.com/lit/ds/symlink/tms320f28377d.pdf

    .

    You can dedicate couple of Flash sectors for data and you can use them to program your counter data.  Refer to this thread on how you can use Flash for this purpose:  

    Use EEPROM(Flash) for data retention in TMS320F2808 Microcontroller - C2000 microcontrollers forum -...

    e2e.ti.com
    Other Parts Discussed in Thread: TMS320F2808 , CONTROLSUITE Hi, I am working on TMS320F2808 Microcontroller.I am facing some issues in retaining the data once

    You can use F021_API_F2837xD_FPU32.lib (Flash API library) to erase/program the Flash.  This library is available at controlSUITE\device_support\F2837xD\v210\F2837xD_common\lib.

    Flash API usage example is also available at controlSUITE\device_support\F2837xD\v210\F2837xD_examples_Dual\flash_programming.

    Flash API documentation is available at controlSUITE\device_support\F2837xD\v210\doc\FlashAPI_Doc.

    Note that you can not erase/program Flash while executing the code from Flash.  Hence, you need to have a RAM run address for Flash API functions (and for the functions that call the Flash API functions) as shown in the example mentioned above.

    Hope this helps.

    Thanks and regards,

    Vamsi

  • Thanks for the quick response. one last question, if i want to boot my program from the flash i cant read/write from other unused flash sectors?

    how should i boot my program from a RAM? you meant the internal or external RAM??
  • Shimon,

    I think you are asking about my suggestion of running the Flash API from RAM.  Flash bank on F2837xD should not be accessed (for fetches/reads) when a Flash erase/program operation is in progress on that bank.  Hence, you can not execute the Flash API from the Flash bank on which you want to perform erase/program operations.  Instead you can assign the Flash API library to .TI.ramfunc section (check flash_programming_cpu1_FLASH.cmd file at controlSUITE\device_support\F2837xD\v210\F2837xD_examples_Dual\flash_programming\cpu01) and copy the Flash API functions from Flash to internal RAM at run time using memcpy() function before executing the Flash API functions.  This way, the Flash API gets loaded to Flash but will be copied to RAM for doing erase/program operations on the Flash bank.

    If you step-in to the InitSysCtrl() function in the example that I pointed to you in my previous reply on this post, you will notice the memcpy() function usage.

    Let me know if you have any questions.

    Thanks and regards,

    Vamsi

     

  • Thanks!

    but i see that for this issue, implementing a time counter in the internal flash is not a quiet good idea because every write of new value demands a erase of the entire sector..

    so my next question is, if in any chance there's some kind of time counter on chip in the TMS320f28377D??

    Thanks.
  • for example, the ipc free running counter.

    after reset the counter resets or saves the last number stored?
  • Shimon,

    You don't have to erase the sector every time you want to update the value.  You can implement a simple EEPROM emulation method in Flash as explained in https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/319481 - This way you don't have to erase the Flash for every update.  

    You can implement the timer in RAM (or check for CPU Timers in TRM at http://www.ti.com/lit/ug/spruhm8f/spruhm8f.pdf) and update the value in Flash before a power down.  CPU Timers in the device get reset for a power cycle/reset.    

    Thanks and regards,

    Vamsi

  • Hi Vamsi

    thanks for the info. the link to the thread links to other thread, where they reccomended using the Eeprom emulator. i will check this out. 

    Thanks!

  • hi Vamsi

    i'm working with the Sprab69 document and example. i checked it out and and noticed that the example is relevant to the 2833 family. i'm working with the F2837xD. is it relevant?
  • Shimon,

    The EEPROM concept is similar.  However, the Flash API functions that you use are different between the two devices.

    Also, F2837xD Flash has ECC.  This will require you to program a minimum of 64-bits (aligned on 64-bit boundary) at a time on F2837xD.  Hence, you have to allocate a minimum of 64-bits for a variable even if it needs only 16-bits or 32-bits.  

    Thanks and regards,

    Vamsi

  • Hi Vamsi

    Thanks for the help

    but i cant find many functions and variables that ahs been used in the eeprom emulator example.. such as memcopy(..) function. this function should be in string.h file but i cant find it...

    can you help?
  • Shimon,

    memcpy() is part of RTS library now.

    Please note that we don't have a EEPROM solution for F2837xD device. EEPROM functions that you see in that document can not be used directly for this device. I asked you to go through it so you can develop a solution as needed.

    Thanks and regards,
    Vamsi
  • Hi vamsi,

    i understand, but the issue right now is the following line:

    memcopy(&Flash28_API_LoadStart,&Flash28_API_LoadEnd,&Flash28_API_RunStart)

    in the Eeprom example, those variables located in the Flash2823x_API_Library.h file. wher i can find the vriables in my project?
  • Shimon,

    In F2823x device linker cmd files, we used to use two sets of symbols - one set for ramfuncs and another set for Flash28_API as copied below from the corresponding linker command file.  

       Flash28_API:
       {
            -lFlash28335_API_V210.lib(.econst) 
            -lFlash28335_API_V210.lib(.text)
       }                   LOAD = FLASHD, 
                           RUN = RAML0,  
                           LOAD_START(_Flash28_API_LoadStart),
                           LOAD_END(_Flash28_API_LoadEnd),
                           RUN_START(_Flash28_API_RunStart),
                           PAGE = 0
       
       ramfuncs     : LOAD = FLASHD, 
                             RUN = RAML0, 
                             LOAD_START(_RamfuncsLoadStart),
                             LOAD_END(_RamfuncsLoadEnd),
                             RUN_START(_RamfuncsRunStart),
                             PAGE = 0

    For the F2837xD and other latest devices, we are using only one set of symbols for both the ".TI.ramfunc" section and the Flash API library as shown below by using GROUP directive (Below is taken from controlSUITE\device_support\F2837xD\vx\F2837xD_examples_Dual\flash_programming\cpu01flash_programming_cpu1_FLASH.cmd file).  These symbols are defined by the linker during the link step.  All these symbols are declared in F2837xD_GlobalPrototypes.h file.

            GROUP
            {
                .TI.ramfunc
                { -l F021_API_F2837xD_FPU32.lib}
             
            } LOAD = FLASHD,
              RUN  = RAMLS03, 
              LOAD_START(_RamfuncsLoadStart),
              LOAD_SIZE(_RamfuncsLoadSize),
              LOAD_END(_RamfuncsLoadEnd),
              RUN_START(_RamfuncsRunStart),
              RUN_SIZE(_RamfuncsRunSize),
              RUN_END(_RamfuncsRunEnd),
              PAGE = 0 

    Thanks and regards,

    Vamsi