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.

TMS320F280049C: Fapi_issueProgrammingCommand always produces FMSTAT INVDAT to be 1

Expert 2730 points
Part Number: TMS320F280049C


Hi,

I'm trying to use the flash API and try to program FLASH but it always returns failure. From the manual the INVDAT will be set if I'm trying to write 0 to 1 in flash. Before I write to FLASH I have erased the flash (also checked with functions everything is OK and with memory browser that is is all 0xFFFF) but it doesn't help. What am I doing wrong?

Here is some code how am I trying to do it:

uint32_t addressToErase = 0x8F000;
uint16_t data[4];
data[0] = 0x10;
data[1] = 0x11;
data[2] = 0x12;
data[3] = 0x13;

Fapi_StatusType flashStatus = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *)addressToErase);
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady);
if (flashStatus != 0)
{
    // Handle error
}
else
{
     if (Fapi_getFsmStatus() != 0u)
     {
         // Handle error
     }
     else
     {
        // Check if blank
        Fapi_FlashStatusWordType flashStatusWord;
        flashStatus = Fapi_doBlankCheck((uint32_t *)addressToErase, 0x1000, &flashStatusWord);
        if (flashStatus != Fapi_Status_Success)
        {
            // Handle error
        }
        else
        {
            flashStatus = Fapi_issueProgrammingCommand(&addressToErase, &data[0], 4, NULL, 0u, Fapi_AutoEccGeneration);
            // Wait until the Flash program operation is over
            while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady);
            if (flashStatus != Fapi_Status_Success)
            {
                Will always come here because INVDAT is 1
                // Handle error
            }
            ....

        }
     }
}

  • I just tested my code (because that's not the actual code I'm using but only the relevant parts) and noticed that if the buffer is only 4 words, I will get  Fapi_Error_AsyncIncorrectDataBufferLength error even though I only want to write 4 words. Why is that? In my actual code the buffer is much bigger but it should not matter in this case. I increased the buffer for this example to be 8 words and I get a gain INVDAT 1 error.

    JHi

  • Just found out what it was. My address to program command is wrong. It really should point to address where I wan't to program like in blank check:

    Fapi_issueProgrammingCommand(&addressToErase, &data[0], 4, NULL, 0u, Fapi_AutoEccGeneration);

    should be

    Fapi_issueProgrammingCommand((uint32_t *)addressToErase, &data[0], 4, NULL, 0u, Fapi_AutoEccGeneration);

    JHi

  • JHi,

    Glad it is working for you now.

    Please search for "How many bits can be programmed at a time using Fapi_issueProgrammingCommand()?" in the Flash API wiki at https://processors.wiki.ti.com/index.php/C2000_Flash_FAQ

    Thanks and regards,
    Vamsi