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.

TMS320F2800137: issue of erasing all flash sector from RAM

Part Number: TMS320F2800137

Hi Expert,

there seem have issue of erasing all flash sector from RAM on F2800137 while the same operation is ok for F280025.

The code of erasing all flash sector is listed below, after running the below code from RAM, all flash sector do have been erased, but the code will run to ROM address as showed below rather than into while loop also run from RAM.  

#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#else
#pragma CODE_SECTION(Example_EraseBanks, ".TI.ramfunc");
#endif
void Example_EraseBanks(void)
{
    Fapi_StatusType  oReturnCheck;
    Fapi_FlashStatusType  oFlashStatus;
    Fapi_FlashStatusWordType  oFlashStatusWord;
    uint32 u32CurrentAddress = 0;
    uint32 i;
    ClearFSMStatus();

    // Enable program/erase protection for select sectors where this example is 
    // located
    // CMDWEPROTA is applicable for sectors 0-31
    // Bits 0-11 of CMDWEPROTB is applicable for sectors 32-127, each bit represents
    // a group of 8 sectors, e.g
    //bit 0 represents sectors 32-39, bit 1 represents
    // sectors 40-47, etc
    //

//    Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTA, 0x13FFFF00);
//    Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTB, 0x00000080);
    Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTA, 0x00000000);
    Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTB, 0x00000000);
    u32CurrentAddress = Bzero_Sector0_start;

    //
    //Issue bank erase command
    //
    for(i=0;i<128;i++)
    {
    oReturnCheck = Fapi_issueBankEraseCommand((uint32 *)u32CurrentAddress+(i<<10));

    //
    // Wait until FSM is done with erase sector operation
    //
 while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
 
    }
}

If I do the same operation on F280025 with the similar code below, then the code will erase all flash and then run to while loop that run from RAM.

void Example_EraseSector(void)
{
    Fapi_StatusType  oReturnCheck;
    Fapi_FlashStatusType  oFlashStatus;
    Fapi_FlashStatusWordType  oFlashStatusWord;
uint16 i =0;
    //
    // Erase the sector that is programmed in the above example
    // Erase Sector6
    //
    for(i=0;i<16;i++)
    {
    oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
                   (uint32 *)Bzero_Sector0_start+(i<<12));
    //
    // Wait until FSM is done with erase sector operation
    //
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}



    }
}

I don't know why there have difference between F280013x and F280025, both are tested based on example code. 

I post both two code here for comparison, could you help explain if anything wrong ?

https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/171/flashapi_5F00_ex1_5F00_programming_5F00_F280013_5F00_issue.7z

https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/171/flashapi_5F00_ex1_5F00_programming_5F00_f280025_5F00_ok.7z