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:闪存擦除

Guru**** 2601915 points
Other Parts Discussed in Thread: TMS320F28388D, C2000WARE

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1025811/tms320f28388d-flash-erase

器件型号:TMS320F28388D
主题中讨论的其他器件: C2000WARE

你(们)好  

我正在使用 F28388D 控制器、您能否检查代码初始化是否正确、从现在起、我已禁用 ECC、但一旦它仅用于数据、就会启用 ECC。 当外部看门狗被禁用时、它工作正常。  您能不能告诉我我 是否可以每1ms 中断一次 CPU 定时器2、或者您可以建议何时发出擦除命令。

#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
    {

    }

}

您能不能告诉我我 是否可以每1ms 中断一次 CPU 定时器2、或者您可以建议何时发出擦除命令。

谢谢、

Nagesh

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!  

    我忘记了提及其他函数定义

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

    谢谢

    Nagesh

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Nagesh、

    您能否确认您的 ISR 和闪存操作函数都是从 RAM 执行而不访问闪存?

    为什么要使用 ramfuncs?  请改用.TI.ramfunc 段。

    谢谢、此致、
    Vamsi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Vamsi、  

    我在 RAM 中有闪存 API 库、在链接器 cmd 中进行了如下更新



    ramfuncs
    {-l RTS_TMS320F28388D_FlashAPI.lib}
    }负载= FLASH0 | FLASH1 | FLASH2 | FLASH3、
    运行= RAMLS0123,
    Load_start (RamfuncsLoadStart)、
    load_size (RamfuncsLoadSize)、
    Load_End (RamfuncsLoadEnd)、
    RUN_START (RamfuncsRunStart)、
    run_size (RamfuncsRunSize)、
    RUN_END (RamfuncsRunEnd)、
    对齐(8)

    因此、理想情况下、我认为两者都是相同 的.TI.ramfunc 或 ramfuncs。 请告诉我这一点是否重要。 闪存 API 库名称已更改、但与您提供的名称相同。

    是的、我在 RAM 中有 ISR 和闪存函数。

    谢谢、

    Nagesh

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Nagesh、

    请使用.TI.ramfunc 并查看其运行情况。

    请查看 C2000Ware 中的最新链接器 cmd 文件。

    注意:对于较新的编译器版本、我们将为 ramfunction 段使用较新的名称".TI.ramfunc"。 从技术上讲、这两种方法都应该起作用、但它依赖于链接器段的命名以及要对齐的代码中使用的 pragma。  如果您将代码中的任何引用从 ramfuncs 切换到.TI.ramfunc、它也应该与.TI.ramfunc 一起使用。

    Thansk 和此致、
    Vamsi