主题中讨论的其他器件: 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