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.

TMS320F28379D: EEPROM Emulation - How to avoid erasing of flash sector containing calibration data...

Part Number: TMS320F28379D

Hi all,

I am trying to develop a MATLAB/Simulink based reference example for EEPROM Emulation.

I have used sector N of the flash to save the calibration data. I copy these calibration values to RAM during system initialization, allow user to modify/update them, then save the updated parameter value to Flash(Sector N). This is all working fine for now.

But there is a small issue. When we build the code and load it to flash next time (from MATLAB/Simulink) we will erase the entire flash and load the .out file.

Hence, whatever the calibration parameters were updated previously in the sector 'N' would now be erased and loaded with default values again.

So every time we build the model and download the code from MATLAB/Simulink, we are seeing this issue.

So my question is:

How to avoid erasing of flash sector containing calibration data?

Right now as part of build and load process, we are invoking the runProgram.js file, that I believe is responsible for loading operation.

Inside the script the following line of code is probably doing the erase operation.

// Load the program -------------------------------
print("\n*** Loading the program to the target...")
debugSession.memory.loadProgram(programName);

So, how can we ensure that next time user wants to download the model file, he would not touch the calibration sector.

In CCS, we can uncheck which sectors to erase. How can we achieve the same with the runProgram.js script.?

  • Venkatesh,

    We should be able to replicate "uncheck sectors" for the script as well.

    We will get back to you in a day or two with the details.

    Thanks and regards,
    Vamsi

  • In CCS, we can uncheck which sectors to erase. How can we achieve the same with the runProgram.js script.?

    You can use the DSS flash option APIs.

    See:

    <CCS INSTALL DIR>/ccs/ccs_base/scripting/docs/DS_API/com/ti/debug/engine/scripting/Flash.html

    <CCS INSTALL DIR>/ccs/ccs_base/scripting/docs/DS_API/com/ti/debug/engine/scripting/Options.html

    There is a DSS example that uses some of these APIs in:

    <CCS INSTALL DIR>/ccs/ccs_base/scripting/examples/DebugServerExamples/f28335_flash.js

    For example, if you wish to tweak the flash settings so that only sector N is not erased, you can do something like:

    session.flash.options.setString("FlashEraseSelection","Selected Sectors Only");

    session.flash.options.setBoolean("FlashC28Bank0Sector13",false);
    The above first line will change the flash options to only erase selected sectors only. Since all sectors are selected by default, the above second line will de-select (uncheck) sector N (by setting it to "false").
    Note that I tested the above using an F28377D. I'm not sure how different the id names would be for an F28379D. I'm guessing that they are similar (you can confirm by running session.flash.options.printOptions(".*") to get the full list of options/ids).
    Thanks
    ki