ZHCAEX4 January   2025 F29H850TU , F29H859TU-Q1

 

  1.   1
  2.   摘要
  3.   商标
  4. 简介
  5. EEPROM 与片上闪存的区别
  6. 概述
    1. 3.1 基本概念
    2. 3.2 单存储单元方法
    3. 3.3 乒乓方法
    4. 3.4 创建 EEPROM 节(页)和页标识
  7. 软件说明
    1. 4.1 软件功能和流程
  8. 单存储单元仿真
    1. 5.1 用户配置
      1. 5.1.1 EEPROM_Config.h
      2. 5.1.2 F29H85x_EEPROM.c
    2. 5.2 EEPROM 函数
      1. 5.2.1 初始化和设置函数
        1. 5.2.1.1 Configure_Device
        2. 5.2.1.2 EEPROM_Config_Check
      2. 5.2.2 页面模式函数
        1. 5.2.2.1 EEPROM_GetValidBank
        2. 5.2.2.2 EEPROM_UpdateBankStatus
        3. 5.2.2.3 EEPROM_UpdatePageStatus
        4. 5.2.2.4 EEPROM_UpdatePageData
        5. 5.2.2.5 EEPROM_Write_Page
      3. 5.2.3 64 位模式函数
        1. 5.2.3.1 EEPROM_64_Bit_Mode_Check_EOS
        2. 5.2.3.2 EEPROM_Write_64_Bits
      4. 5.2.4 两种模式下使用的函数
        1. 5.2.4.1 EEPROM_Erase
        2. 5.2.4.2 EEPROM_Read
      5. 5.2.5 实用功能
        1. 5.2.5.1 EEPROM_Write_Buffer
        2. 5.2.5.2 Erase_Bank
        3. 5.2.5.3 Set_Protection_Masks
        4. 5.2.5.4 Configure_Protection_Masks
        5. 5.2.5.5 Fill_Buffer
        6. 5.2.5.6 ClearFSMStatus
    3. 5.3 测试示例
  9. 乒乓仿真
    1. 6.1 用户配置
      1. 6.1.1 EEPROM_PingPong_Config.h
      2. 6.1.2 F29H85x_EEPROM_PingPong.c
    2. 6.2 EEPROM 函数
      1. 6.2.1 初始化和设置函数
        1. 6.2.1.1 Configure_Device
        2. 6.2.1.2 EEPROM_Config_Check
      2. 6.2.2 页面模式函数
        1. 6.2.2.1 EEPROM_GetValidBank
        2. 6.2.2.2 EEPROM_UpdateBankStatus
        3. 6.2.2.3 EEPROM_UpdatePageStatus
        4. 6.2.2.4 EEPROM_UpdatePageData
        5. 6.2.2.5 EEPROM_Write_Page
      3. 6.2.3 64 位模式函数
        1. 6.2.3.1 EEPROM_64_Bit_Mode_Check_EOS
        2. 6.2.3.2 EEPROM_Write_64_Bits
      4. 6.2.4 两种模式下使用的函数
        1. 6.2.4.1 EEPROM_Erase_Inactive_Unit
        2. 6.2.4.2 EEPROM_Read
        3. 6.2.4.3 EEPROM_Erase_All
      5. 6.2.5 实用功能
        1. 6.2.5.1 EEPROM_Write_Buffer
        2. 6.2.5.2 Erase_Bank
        3. 6.2.5.3 Configure_Protection_Masks
        4. 6.2.5.4 Set_Protection_Masks
        5. 6.2.5.5 Fill_Buffer
        6. 6.2.5.6 ClearFSMStatus
    3. 6.3 测试示例
  10. 应用集成
  11. 闪存 API
    1. 8.1 闪存 API 检查清单
      1. 8.1.1 使用闪存 API 时的注意事项
  12. 源文件清单
  13. 10故障排除
    1. 10.1 一般
  14. 11结语
  15. 12参考资料

Erase_Bank

Erase_Bank 函数利用闪存 API 来擦除已满 EEPROM 单元。此函数只是围绕闪存 API 的包装程序,并且保护掩码已在 EEPROM_Erase() 函数中设置。

首先,函数会清除 FSM 状态并将保护掩码复制到闪存 API 中。

ClearFSMStatus(FLASH_BANK_SELECT, u32UserFlashConfig);

Fapi_setupBankSectorEnable((uint32_t*) FLASH_BANK_SELECT, u32UserFlashConfig,
        FLASH_NOWRAPPER_O_CMDWEPROTA, WE_Protection_A_Mask);

Fapi_setupBankSectorEnable((uint32_t*) FLASH_BANK_SELECT, u32UserFlashConfig,
        FLASH_NOWRAPPER_O_CMDWEPROTB, WE_Protection_B_Mask);

然后,函数会擦除闪存并检查是否存在编程错误。

oReturnCheck = Fapi_issueBankEraseCommand((uint32_t*) FLASH_BANK_SELECT, 0, u32UserFlashConfig);

while(Fapi_checkFsmForReady((uint32_t) FLASH_BANK_SELECT, u32UserFlashConfig) == Fapi_Status_FsmBusy);

if (oReturnCheck != Fapi_Status_Success)
    Sample_Error();

oFlashStatus = Fapi_getFsmStatus((uint32_t) FLASH_BANK_SELECT, u32UserFlashConfig);
if (oFlashStatus != 3)
{
    FMSTAT_Fail();
}

最后,如果已设置 Erase_Blank_Check,则执行空白检查。

if (Erase_Blank_Check)
{
    uint32_t address = FLASH_BANK_SELECT + FIRST_AND_LAST_SECTOR[EEPROM_ACTIVE_UNIT][0] * FLASH_SECTOR_SIZE;
    Fapi_FlashStatusWordType oFlashStatusWord;
    oReturnCheck = Fapi_doBlankCheck((uint32_t*) address, BLANK_CHECK_LEN, &oFlashStatusWord, 0,
                u32UserFlashConfig);
    if (oReturnCheck != Fapi_Status_Success)
    {
        Sample_Error();
    }
}