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.

TMS320F28379S: FLASH API reporting success, but not programming.

Part Number: TMS320F28379S


I'm trying to get a handle on how to use the FLASH on a TI Delfino single core processor.

I started with this:

    Fapi_StatusType oReturnCheck;

    InitFlash_Bank0();
    InitFlash_Bank1();

    EALLOW;
    PUMPREQUEST = 0x5A5A0002;

    oReturnCheck = Fapi_initializeAPI(F021_CPU0_W0_BASE_ADDRESS, 200);
    if(oReturnCheck != Fapi_Status_Success)
    {
        //
        // Check Flash API documentation for possible errors
        //
        return -1;
    }

    //
    // Fapi_setActiveFlashBank function sets the Flash bank and FMC for further
    // Flash operations to be performed on the bank
    //
    oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    if(oReturnCheck != Fapi_Status_Success)
    {
        //
        // Check Flash API documentation for possible errors
        //
        return -2;
    }

    EDIS;

    return oReturnCheck;

Then I tried to write to memory:

    Fapi_StatusType ret;
    uint32 *addr = (Uint32 *)Bzero_SectorC_start + 8*sel;
    uint16 dbuf[2];

    dbuf[0] = val & 0xFFFF;
    dbuf[1] = (val>>16) & 0xFFFF;
    EALLOW;
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    ret = Fapi_issueProgrammingCommand(addr,dbuf,2,0,0,Fapi_DataOnly);
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    EDIS;
    return (int)ret;

And subsequently read back:

    Fapi_FlashStatusWordType status;
    uint32 *addr = (Uint32 *)Bzero_SectorC_start + 8*sel;
    uint32 rcvBuf = 0;
    EALLOW;
    if(Fapi_doBlankCheck(addr,1,&status)){
        rcvBuf = status.au32StatusWord[1];
    }else{
        return 0;
    }

    EDIS;
    //Shift down by 16 if onoff==0
    rcvBuf = (rcvBuf >>(16 * (!onoff)));
    return (Uint16)rcvBuf;

I was hoping that rcvBuf would be equal to the value provided during the write attempt, but instead it shows 0x0001AA00, which is the same value it started with.

However, when debugging, the return value from the Flash Write is always Fapi_Status_Success, implying it wrote correctly. So why doesn't the readback value ever change from 0x0001AA00, no matter how many times I try to write over it?

  • Hi Dan,

    Did you erase the sector before programming?  You mentioned that you programmed some data on the existing 0x0001AA00 data.  You should first erase the sector before you can reprogram that sector. Please check and confirm.

    Also, instead of Fapi_doBlankCheck(), I would suggest you to use Fapi_doVerify() for verifying the contents that you programmed.  Fapi_doBlankCheck() is used to verify that the sector is erased (I understand that there is no issue in the way you coded, but the intention of the provided function is different).

    Regarding your question on success return from Flash API, please search for below questions in the Flash API wiki at processors.wiki.ti.com/.../C2000_Flash_FAQ

    - Does Fapi_issueProgrammingCommand() function call return after completing the program operation?  

    - If the Fapi_issueProgrammingCommand() function does not wait for the program operation completion, how do we know whether the program operation succeeded or not?

    I would also suggest you to disable ECC before reading the Flash memory (either using Fapi_doVerify() or your own code) since you are not programming ECC (you are using Fapi_DataOnly).  This helps to avoid ECC errors.  You can enable ECC after you verify.  Instead, you can use Fapi_AutoEccGeneration mode - This mode calculates and programs ECC automatically when you program Flash.

    Let me know if you have further questions.

    F2837xS Flash API (V1.55) reference guide link: http://www.ti.com/lit/pdf/spnu630

    Thanks and regards,

    Vamsi