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.

TMS320F28P550SJ: NVM Erase at SW reset

Part Number: TMS320F28P550SJ
Other Parts Discussed in Thread: C2000WARE

Hi,

 

I am using C2000Ware_6_00_00_00 example provided for the EEPROM Ping Pong model. The NVM is erased every time with a Soft reset because of Erase function is called during EEPROM_Config_Check everytime. Is there a check that can be added to prevent calling the erase function by checking if data is available in the bank and reset only one time during the initialization and not for every Soft reset.

  • Hi Srikanth,

    The C2000Ware EEPROM Ping Pong example does not include a built-in mechanism to skip the erase when valid data already exists in the bank. You'll need to add a custom validation check before the erase call inside EEPROM_Config_Check to conditionally skip it.

    Recommended Approach: Magic Number / Signature Check

    On C2000 flash, an erase sets all bits to 1 (i.e., erased flash reads as 0xFFFF). You can exploit this to detect whether a bank already contains valid data:

    1. Reserve a known location in each NVM bank for a "magic number" or signature (e.g., 0xA5A5 or any value that is not 0xFFFF).

    2. Before calling the erase function in EEPROM_Config_Check, read that location. If the signature is present and valid, skip the erase — the bank already has initialized data.

    3. Only erase if the signature location reads 0xFFFF (blank/erased) or contains an unexpected value (corrupted data).

    Pseudocode example:

    // At the start of EEPROM_Config_Check, before the erase call:
    uint16_t signature = *(volatile uint16_t *)EEPROM_BANK_SIGNATURE_ADDR;
    
    if (signature == EEPROM_VALID_SIGNATURE)
    {
    // Valid data exists — skip erase, proceed to normal operation
    return;
    }
    
    // Signature not found — first-time init or corrupted bank
    // Proceed with erase and then write the signature after initialization
    Fapi_issueAsyncCommandWithAddress(Fapi_EraseBank, ...);
    // ... after erase and initial data programming ...
    // Program the signature to mark the bank as initialized
    1. Write the signature as the last step after a successful erase + initial data programming. This ensures that if power is lost mid-erase, the signature won't be present and the erase will correctly re-run on the next boot.

    Why This Works

    • Fapi_doBlankCheck() checks if flash main array equals 0xFFFF — it confirms whether a region is erased. You could also use this API call instead of (or in addition to) a magic number to determine bank state.
    • The Flash API does not track erase counts or initialization state automatically — this must be managed in your application code.

    Additional Consideration

    You can also use Fapi_doBlankCheck() directly on the data region of the bank. If it returns that the bank is not blank, you know data has been programmed and you can skip the erase. However, a dedicated signature/magic number is more robust because it distinguishes between "valid initialized data" and "partially written/corrupted data."

    Best Regards,

    Zackary Fleenor