ZHCADD5A November 2023 – April 2024 TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DH-Q1 , TMS320F28P659DK-Q1 , TMS320F28P659SH-Q1
EEPROM_UpdatePageData() 函数的功能是更新 EEPROM 页数据。此函数由 EEPROM_Write() 函数调用。
为了实现这一目标,需要采取以下步骤:
// Clears status of previous Flash operation
ClearFSMStatus();
Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTA, WE_Protection_A_Mask);
Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTB, WE_Protection_B_Mask);
// Variable for page offset
//(first write position has offset of 2 (64 bits),
// second has offset of 4 (128 bits), etc.)
uint32 Page_Offset = 4 + (2 * i);
// Program data located in Write_Buffer to current page
oReturnCheck = Fapi_issueProgrammingCommand((uint32*) Page_Pointer + Page_Offset,Write_Buffer + (i*4), 4, 0, 0,Fapi_AutoEccGeneration);
// Wait for completion and check for any programming errors
EEPROM_CheckStatus(&oReturnCheck);
以下参数被传递至闪存 API 以进行编程。
使用 Fapi_AutoEccGeneration 模式时,第四个和第五个参数为零。有关更多详细信息,请参阅 TMS320F28P65x 闪存 API 版本 3.02.00.00 参考指南。
如果编程成功,则会更新当前页面的页面状态并清除 Empty_EEPROM 标志。代码如下所示:
if(oReturnCheck == Fapi_Status_Success) { // Set Page Status to Current Page Page_Status[0] = CURRENT_PAGE; Page_Status[1] = CURRENT_PAGE; Page_Status[2] = CURRENT_PAGE; Page_Status[3] = CURRENT_PAGE; Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTA, WE_Protection_A_Mask); Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTB, WE_Protection_B_Mask); oReturnCheck = Fapi_issueProgrammingCommand((uint32*)Page_Pointer, Page_Status, 4, 0, 0, Fapi_AutoEccGeneration); // Wait for completion and check for any programming errors EEPROM_CheckStatus(&oReturnCheck); Empty_EEPROM = 0; } if (Erase_Inactive_Unit) { // Erase the inactive (full) EEPROM Bank Erase_Inactive_Unit = 0; }