Thread 中讨论的其他器件: controlSUITE、 SYSBIOS
您好!
我们正在尝试使用闪存 API 写入 F28M35H52C 处理器的闪存。
我们遇到随机故障、函数与 Fapi_setActiveFlashBank 函数卡住。 我们使用闪存组0。
该功能永远不会出现、并且在问题发生后器件崩溃。
我随附了代码供您参考:
我们已使用链接器文件将闪存 API 放置在 RAM 中。 在执行期间、它不会被放置在闪存中(然后被复制到 RAM 中)。
调用闪存 API 的函数也被放置在 RAM 中。
您能不能回顾一下代码片段、如果我们错过了任何内容、请告知我们。 如果需要、我们可以提供更多详细信息。
uint32_t Fapi_BlockProgram( uint32 u32address, uint8 *u8Data, uint32 SizeInBytes, uint8 u8Writelength)
{
Fapi_StatusType oReturnCheck;
volatile Fapi_FlashStatusType oFlashStatus;
uint8_t bytes = 0;
// To acces the Flash_api
FlashGainPump();
if (SizeInBytes < u8Writelength)
bytes = SizeInBytes;
else
bytes = u8Writelength;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 75);
if(oReturnCheck != Fapi_Status_Success)
{
//Check Flash API documentation for possible errors
//Example_Error(oReturnCheck);
#if SYSTEM_TEST_GEN2_2_ERROR
printk("Flash_api Initialize issue : %d \n",oReturnCheck);
// Send error code to error handler task for processing
ProcessSystemError(ERROR_PPS_FLASH_ACCESS_FAILURE, PPS_TASK_CAN); // 1008
#endif
}
// Fapi_setActiveFlashBank function sets the Flash bank and FMC
// for further Flash operations to be performed on the bank
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success)
{
// Check Flash API documentation for possible errors
//Example_Error(oReturnCheck);
#if SYSTEM_TEST_GEN2_2_ERROR
printk("Flash_api Flash_Bank issue : %d \n",oReturnCheck);
// Send error code to error handler task for processing
ProcessSystemError(ERROR_PPS_FLASH_ACCESS_FAILURE, PPS_TASK_CAN); // 1008
#endif
}
while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
// Disable ECC so that error is not generated when reading Flash
// contents without ECC
HWREG(FLASH_ERROR_BASE + FLASHERR_O_ECC_ENABLE) = 0x0;
while( SizeInBytes > 0)
{
oReturnCheck = Fapi_issueProgrammingCommand( (uint32 *)u32address,(uint8 *)u8Data, bytes, 0, 0, Fapi_AutoEccGeneration);
while( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy );
//while( Fapi_getFsmStatus() != Fapi_Status_Success);
printk("Flash_api write Done :[ %x ], Length : %d \n",u32address, SizeInBytes);
if(oReturnCheck != Fapi_Status_Success)
{
// Check Flash API documentation for possible errors
//Example_Error(oReturnCheck);
#if SYSTEM_TEST_GEN2_2_ERROR
printk("Flash_api write issue : %d \n",oReturnCheck);
// Send error code to error handler task for processing
ProcessSystemError(ERROR_PPS_FLASH_WRITE_FAILURE, PPS_TASK_CAN); // 1008
#endif
}
u32address += bytes;
u8Data += bytes;
SizeInBytes -= bytes;
if ( SizeInBytes < u8Writelength)
{
bytes = SizeInBytes;
}
}
// Enable ECC
HWREG(FLASH_ERROR_BASE + FLASHERR_O_ECC_ENABLE) = 0xA;
// Leave control over pump
FlashLeavePump();
return (0);
}
此致、
Lakshmi
