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.

LAUNCHXL-F28379D: F28379D - F021 Flash API : Fapi_issueAsyncCommandWithAddress is not erasing the sector

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Hi everyone,

I am trying to erase one sector after a CAN message has been received on the F28379D micro. However, the Fapi_issueAsyncCommandWithAddress function does not erase anything.

Here is a sample of my code that I use in order to erase the sector (sectorAddr variable is a uint32_t) :

    SeizeFlashPump();

    // Disable ECC so that error is not generated when reading Flash contents
    // without ECC
    Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;

    // Wait until the operation is over
    while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady)
    {}

    puSectorAddr = (uint32 *)sectorAddr;

    //Set the FSM to erase the sector
    status = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, puSectorAddr);

    // Wait until the erase operation is over
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady)
    {}

    // Read FMSTAT register contents to know the status of FSM
    // after erase command to see if there are any erase operation
    // related errors
    flashStatus = Fapi_getFsmStatus();
    if (flashStatus != 0)
    {
        //error on erase
        status = Fapi_Error_Fail;
    }

After this, I am using the Fapi_doBlankCheck to confirm the erase and nothing happened (it returned that the first 32 bit address which is checked is not at 0xFFFFFFFF)..

I am using the F021 API v1.54, on CCS 8.2.0.00007.

Thank you in advance,

Best regards

  • Hi,

    What is the value of puSectorAddr?

    Did you call Fapi_initializeAPI and Fapi_setActiveFlashBank before making the call to Fapi_issueAsyncCommandWithAddress

    Could you please refer below example to check if you have missed anything.

    \C2000Ware_2_00_00_02\device_support\f2837xd\examples\dual\flash_programming

    Thanks,

    Katta

  • Hi,

    First of all thank you for your feedback.

    • puSectorAddr is a pointer on one of these two addresses :
      • 0x000A0000 (start address of Sector H)
      • 0x00098000 (start address of Sector G)
    • I called Fapi_initializeAPI and Fapi_setActiveFlashBank during the initialization step of my program. They are never called after that, because I only have one active bank and no change of CPU frequency.

    I already referred to this project without noticing any differences with mine for the sector erase operation. The write operation is working perfectly fine.

    Regards

  • Alexis,

    1) Please check whether you called EALLOW or not before calling the Flash API functions.

    2) What is the value of FMSTAT after the erase?

    3) Do you have any DCSM settings programmed?

    Also, please search for "What are the common debug tips that we can consider when Flash API fails to erase or program?" in the Flash API wiki at http://processors.wiki.ti.com/index.php/C2000_Flash_FAQ#Flash_API_wiki

    Thanks and regards,
    Vamsi

  • Vamsi,

    1) EALLOW is called just before the SeizeFlashPump() operation presented previously.

    2) At the first try, the FMSTAT is 0, so nothing is indicating me that an error occurs except the doBlankCheck call. I decided to retry the erase by re-sending the CAN command but then I had a 48 value (16 : Command Status || 32 : Invalid Data) but it doesn't explain the first failure.

    3) No password are set for this debug session. Here is my registers values :

    • DcsmCommonRegs
      • FLSEM : 0x00000000
      • SECTSTAT : 0x3FFFFFFF
      • RAMSTAT : 0xF000FFFF

    • DcsmZ1Regs
      • Z1_LINKPOINTER :  0xFFFFFFFF
      • Z1_OTPSECLOCK : 0x00000FFF
      • Z1_BOOTCTRL : 0xFFFFFFFF
      • Z1_LINKPOINTERERR : 0x00000000
      • Z1_CSMKEY0 : 0xFFFFFFFF
      • Z1_CSMKEY1 : 0xFFFFFFFF
      • Z1_CSMKEY2 : 0xFFFFFFFF
      • Z1_CSMKEY3 : 0xFFFFFFFF
      • Z1_CR : 0x0070
      • Z1_GRABSECTR : 0x3FFFFFFF
      • Z1_GRABRAMR : 0xF000FFFF
      • Z1_EXEONLYSECTR : 0x00007FFF
      • Z1_EXEONLYRAMR : 0x000000FF

    • DcsmZ2Regs
      • Z2_LINKPOINTER : 0xFFFFFFFF
      • Z2_OTPSECLOCK : 0x00000FFF
      • Z2_BOOTCTRL : 0xFFFFFFFF
      • Z2_LINKPOINTERERR : 0x00000000
      • Z2_CSMKEY0 : 0xFFFFFFFF
      • Z2_CSMKEY1 : 0xFFFFFFFF
      • Z2_CSMKEY2 : 0xFFFFFFFF
      • Z2_CSMKEY3 : 0xFFFFFFFF
      • Z2_CR : 0x0070
      • Z2_GRABSECTR : 0x3FFFFFFF
      • Z2_GRABRAMR : 0xF000FFFF
      • Z2_EXEONLYSECTR : 0x00007FFF
      • Z2_EXEONLYRAMR : 0x000000FF

    Thanks and regards

  • Alexis,

    SeizeFlashPump() executes EDIS before returning.  

    Hence, you need EALLOW again after that.

    Please try including EALLOW.

    Thanks and regards,

    Vamsi

  • Vamsi,

    it was the EDIS instruction of the SeizeFlashPump function.

    Thank you and Katta for your help.

    Regards,