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.

TMS320F28388D: Flash Erase

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE

Hi 

I am using F28388D controller, Can you please check the code if the initialization is correct, as of now i have disabled the ECC but will enable it once this is working for data only. it works fine when Ext watchdog is disabled. Can you please let me know if i can interrupt using CPU Timer 2  for every 1msec or any other you can suggest when a erase command is issued.

#pragma CODE_SECTION(InitFlash, "ramfuncs");
void InitFlash(void)
{
    EALLOW;
    //->At reset bank and pump are in sleep. A Flash access will power up the
    // bank and pump automatically.
    // After a Flash access, bank and pump go to low power mode (configurable
    // in FBFALLBACK/FPAC1 registers) if there is no further access to flash.
    // Power up Flash bank and pump. This also sets the fall back mode of
    // flash and pump as active.
    // Set PMPPWR member of gstrFlash0CtrlRegs to 0x1.
    gstrFlash0CtrlRegs.FPAC1.bit.PMPPWR = 0x1;
    //->Set BNKPWR0 member of gstrFlash0CtrlRegs to 0x3.
    gstrFlash0CtrlRegs.FBFALLBACK.bit.BNKPWR0 = 0x3;

    //->Set DATA_CACHE_EN member of gstrFlash0CtrlRegs to 0.
    gstrFlash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 0;
    //->Set PREFETCH_EN member of gstrFlash0CtrlRegs to 0.
    gstrFlash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 0;
    //->Set RWAIT member of gstrFlash0CtrlRegs to 0x3.
    gstrFlash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x3;
    //->Set DATA_CACHE_EN member of gstrFlash0CtrlRegs to 1.
    gstrFlash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 1;
    //->Set PREFETCH_EN member of gstrFlash0CtrlRegs to 1.
    gstrFlash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 1;

    //->At reset, ECC is enabled. If it is disabled by application software and
    // if application again wants to enable ECC.
    // Set ENABLE member of gstrFlash0EccRegs to 0x0.
#warning"ECC disabled!"
    gstrFlash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;

    //-> Disable the write protected registers for write operation.
    EDIS;

    //->Force a pipeline flush to ensure that the write to the last register
    // configured occurs before returning.
    // Invoke __asm with " RPT #7 || NOP" as parameter
    __asm(" RPT #7 || NOP");
}

//I have created a function to erase each sector 4, 5, 6 in a below mentined while loop
//and i need to refresh external WD every 7ms my GPIO to refresh Ext Wd is working .
//but i see it takes more time to erase not getting how its getting stuck in flash api lib
//function call, can i have a interrupt using CPU timer 2 to refresh WD when Erase command is 
// issues.
        while(eFlashErasePrimOfs != Fapi_Status_Success)
        {
            eFlashErasePrimOfs = FdFlashEraseNew((UINT32 *)0x88000); 
            
            TcStartTimer(GBL_FLASH_ERASE_TIMER_7);
            //Delay of 50ms
            while(u32Timer50ms < 50000)
            {
                RefreshWD();
                u32Timer50ms = TcGetTimerCount(GBL_FLASH_ERASE_TIMER_7);
            }
           
            u32Timer50ms = 0;
        }
        
        
#pragma CODE_SECTION(FdFlashEraseNew,"ramfuncs");
Fapi_StatusType FdFlashEraseNew(UINT32 *pu32FlashAddress)
{
    Fapi_StatusType eStatusFlash = Fapi_Error_Fail;

    if(pu32FlashAddress == NULL)
    {
        eStatusFlash = Fapi_Error_Fail;
    }
    else if (eStatusFlash != Fapi_Status_Success)
    {
        FdFlashEraseSector(pu32FlashAddress, &eStatusFlash);
    }
    else
    {

    }

    return eStatusFlash;
}

#pragma CODE_SECTION(FdFlashEraseSector,"ramfuncs");
void FdFlashEraseSector(UINT32 *u32FlashSectorAddr, Fapi_StatusType *eStatusupdate)
{
    static Fapi_StatusType eStatustemp1 = Fapi_Error_Fail;
    static Fapi_StatusType eStatustemp2 = Fapi_Error_Fail;
    static Fapi_StatusType eStatustemp3 = Fapi_Error_Fail;

    if(gu32FlashSectorAddr != u32FlashSectorAddr)
    {
        eStatustemp1 = (Fapi_StatusType)Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(UINT32 *)u32FlashSectorAddr);

        gu32FlashSectorAddr = u32FlashSectorAddr;

    }
    else if(eStatustemp1 == Fapi_Status_Success && eStatustemp2 != Fapi_Status_FsmReady)
    {
        eStatustemp2 = FdFlashOperationStatus();

        *eStatusupdate = eStatustemp2;

    }
    else if(eStatustemp2 == Fapi_Status_FsmReady)
    {
        if(eStatustemp3 != Fapi_Status_Success)
        {
            eStatustemp3 = FdFlashEraseVerify((UINT32 *)u32FlashSectorAddr);
        }
        if(eStatustemp3 == Fapi_Status_Success)
        {
        *eStatusupdate = eStatustemp3;
        gu16MaskFlag = 0;
        eStatustemp2 = Fapi_Error_Fail;
        eStatustemp1 = Fapi_Error_Fail;
        eStatustemp3 = Fapi_Error_Fail;
        }
    }
    else
    {

    }

}

Can you please let me know if i can interrupt using CPU Timer 2  for every 1msec or any other you can suggest when a erase command is issued.

thanks,

Nagesh

  • Hi, 

    I forgot to mention additional function definition

    #pragma CODE_SECTION(FdFlashOperationStatus,"ramfuncs");
    Fapi_StatusType FdFlashOperationStatus(void)
    {
        Fapi_StatusType eStatus = Fapi_Error_Fail;
    
        eStatus = (Fapi_StatusType)Fapi_checkFsmForReady();
    
        return (eStatus);
    }

    thanks

    Nagesh

  • Nagesh,

    Can you confirm that your ISR and flash operation functions are all executed from RAM with no access to flash?

    Why are you using ramfuncs?  Please use .TI.ramfunc section instead.

    Thanks and regards,
    Vamsi

  • Hi Vamsi, 

    I have the flash api lib in RAM, updated in linker cmd as below

    GROUP
    {
    ramfuncs
    { -l rts_TMS320F28388D_FlashAPI.lib}
    } LOAD = FLASH0 | FLASH1 | FLASH2 | FLASH3,
    RUN = RAMLS0123 ,
    LOAD_START(RamfuncsLoadStart),
    LOAD_SIZE(RamfuncsLoadSize),
    LOAD_END(RamfuncsLoadEnd),
    RUN_START(RamfuncsRunStart),
    RUN_SIZE(RamfuncsRunSize),
    RUN_END(RamfuncsRunEnd),
    ALIGN(8)

    So ideally i thought both are same .TI.ramfunc or ramfuncs. let me know if this matters. The flash api lib name is changed but its same as you provided.

    Yes i have ISR and flash functions in RAM.

    thanks,

    Nagesh

  • Nagesh,

    Please use .TI.ramfunc and see how it goes.

    Please take a look at the latest linker cmd files from C2000Ware.

    Note: With the newer compiler versions, we are using a newer name for the ramfunction section, ".TI.ramfunc". Technically either should work, but it relies on both the linker section naming and the pragmas used within the code to be aligned. If you switch any references within code from ramfuncs to .TI.ramfunc it should work with .TI.ramfunc too.

    Thansk and regards,
    Vamsi