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.

TMS320F280025C: My customized data, not writing in flash

Part Number: TMS320F280025C
Other Parts Discussed in Thread: C2000WARE

Hi Team,

There's an issue from the customer need your help:

//cmd declaration :

FLASH_BANK0_SEC8  : origin = 0x088000, length = 0x001000 /* on-chip Flash */

FlashScopeRegsFile               : > FLASH_BANK0_SEC8, type=NOINIT

//Data section and structure declarations 

#pragma DATA_SECTION(scopeRegs,"FlashScopeRegsFile");
volatile FlashScopeRegs_S scopeRegs;

typedef struct FlashScopeRegs_S
{
CalibDataXYZW_S calib;
CHAR brightness;
LONG_INT temperature;
}FlashScopeRegs_S;

FlashScopeRegs_S a;

a.temperature = 37; 

The value after writing is -1 and flash is not successful.

Could you help check this case? Thanks.

Best Regards,

Ben

  • I think writing to flash is WAY more complicated than that. In general, flash memory needs to be erased in sectors first then programmed in smaller blocks, 128 bytes for example.

    TI provides an API for flash memory management. Here's the document for your device:

    https://www.ti.com/lit/ug/spnu631/spnu631.pdf

  • Actually I found a more useful document for your use case: EEPROM Emulation:

    https://www.ti.com/lit/an/sprab69a/sprab69a.pdf

  • Kier is correct: in order to write to the flash, you need to use the Flash API to program it or erase as required. Generally, the way the Flash API works is that you issue it a command (program, erase, verify) and then poll it to find out when the command is complete, as these operations are non-CPU blocking.

    It is also important to note the following if performing EEPROM emulation type operation (i.e. using Flash for data instead of code):

    • Program and erase operations take relatively much more time than SRAM access operations. In particular, erase time can vary quite a bit, and increases over time with the total erase count (the erase pulse count progressively increases as the number of erase cycles accumulates). If there are timing constraints on your write/erase operations, you should consider refactoring your code to do these operations in RAM instead; and think of Flash more in terms of longer-term data storage. Flash write/erase timings are specified in the device data sheet.
    • There is a limit to how many write/erase cycles you can perform in total on any flash memory. This is specified in the device data sheet; beyond these limits, the performance/reliability of the Flash memory is not assured.

    Best regards,
    Ibukun

  • Hi Kier and Ibukun,

    Thank you Kier and Ibukun. 

    But why can the register be read or written, it's same declared.

    And I downloaded the code package inside, Flash2833x_API_Config.h, are these APIs not general to different processors? Dose it more general to use external EEPROM by I2C?

    Best Regards,

    Ben

  • I don't fully understand your questions but...

    But why can the register be read or written

    There's no registers in your sample code. FlashScopeRegsFile is a misleading name and is not a register it's just an address in flash memory. You are trying to read (successful) and write (unsuccessful) to the start of a flash sector. It depends on the processor what happens when you try to write to flash when it is not writeable. In the case of C28x, the attempt is just ignored.

    Flash2833x_API_Config.h

    That's the wrong file for your device. I think you need to look at these files:

    C:\ti\c2000\C2000Ware_4_02_00_00\libraries\flash_api

    Dose it more general to use external EEPROM by I2C?

    I think you are asking whether it is easier to use an external EEPROM by I2C. Yes, that would be my choice if you only have a few kibibytes to store. There's a few EEPROM examples here:

    C:\ti\c2000\C2000Ware_4_02_00_00\driverlib\f28002x\examples\i2c

  • Hello Kier,

    Specific to the question about Flash2833x_API_Config.h, this is for a different device generation and does not apply to F28002x. TI releases a software support package specific to each device, so please make sure you have downloaded the latest C2000ware package and are using the headers/libraries from the F28002x directory inside that package.

    Inside the C2000Ware_4_xx_xx_xx\driverlib\f28002x\examples\flash directory, you will find CCS project examples for using the Flash API to program and erase the device Flash.

    Best regards,
    Ibukun