TMS320F28P550SJ: Issue with Flash Programming using Flash API v4.0.0 (TMS320F28P550)

Part Number: TMS320F28P550SJ


Hello,

I’m having a problem writing data to Flash using Flash API v4.0.0 on the TMS320F28P550SJ9.

Setup:
MCU: TMS320F28P550SJ9
Flash API: v4.0
Interrupts: disabled
Bank 4 is fully reserved for data (no code)
Flash API runs from RAM

Problem:
I’m trying to write data to empty Bank 4 (address 0x100000). The data is split into chunks of 4 words (U16):

1. 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A
2. 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF
3. 0xA5A5, 0xA5A5, 0xA5A5, 0xA5A5
4. 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF
5. 0x0001, 0x0002, 0x0003, 0x0004
6. 0x0005, 0x0006, 0x0006, 0x0007


Before starting the programming procedure, I verify that the target memory is blank: 
1. manually (byte-by-byte comparison) 
2. using Fapi_doBlankCheck 
3. through memory view in CCS 

In all cases, the memory was empty

before_flash.png

Behavior during programming:
1. Data is written in chunks (4 × U16).
2. Chunks 1–4 are programmed correctly.
3. When attempting to program the next chunk, Fapi_getFsmStatus returns 0x101 (decimal: 257).

chunk_1_4.png

According to Flash API v4.0.0 documentation:
1. bit 8: Program command failed because an attempt was made to program a stored value
2. bit 0: Command Done

I’ve checked all addresses and offsets — everything looks correct.
After erasing Bank 4 manually in CCS and restarting the firmware, all data writes correctly

after_manual_erase.png



Code:

uint16_t CHUNKS = length / 4U;

uint16_t CHUNK_NUM = 0;
for(CHUNK_NUM = 0; CHUNK_NUM < CHUNKS; CHUNK_NUM++)
{
        Fapi_StatusType fapi_status_ret = Fapi_Status_FsmBusy;

    while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady);

    volatile Fapi_FlashStatusType flash_status_ret = Fapi_getFsmStatus();

    if(flash_status_ret != 0 )
    {
        fapi_status_ret = Fapi_issueAsyncCommand(Fapi_ClearStatus);

        if(fapi_status_ret != Fapi_Status_Success)
        {
            __asm(" ESTOP0");
            return FALSE;
        }
    }

    flash_status_ret  = Fapi_getFsmStatus();

    uint16_t err = (Fapi_checkFsmForReady() == Fapi_Status_FsmReady) && 
                (flash_status_ret == 0x03U || (flash_status_ret == 0U)) ? FALSE : TRUE;

    if(err == TRUE)
    {
        __asm(" ESTOP0");
        return FALSE;
    }

    if(Fapi_setupBankSectorEnable((FLASH_WRAPPER_PROGRAM_BASE + FLASH_O_CMDWEPROTA), MASK_A) != Fapi_Status_Success)
    {
        __asm(" ESTOP0");
        return FALSE;
    }

    if(Fapi_setupBankSectorEnable((FLASH_WRAPPER_PROGRAM_BASE + FLASH_O_CMDWEPROTB), MASK_B) != Fapi_Status_Success)
    {
        __asm(" ESTOP0");
        return FALSE;
    }


    uint16_t offset = 4U * CHUNK_NUM;

    if(Fapi_Status_Success != Fapi_issueProgrammingCommand( (uint32_t*) (0x100000U + offset),
                                                            (uint16_t*) (data_to_save + offset), 
                                                            4U, NULL, 0U, Fapi_AutoEccGeneration))
    {
        __asm(" ESTOP0");
        return FALSE;
    }

    while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady);

    flash_status_ret = Fapi_getFsmStatus();

    if (flash_status_ret != 0x0U && flash_status_ret != 0x3U)
    {
        __asm(" ESTOP0");
        return FALSE;
    }

}


Question:

What could be causing the inability to program the memory, even though the bank was previously verified as blank?


Thank you in advance for any help!

Best regards,
Karol