SPRADL4 January   2025 F29H850DM , F29H850TU , F29H859TU-Q1 , F29P329SM-Q1 , F29P589DM-Q1 , F29P589DU-Q1

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1 Introduction
  5. 2 Differences Between EEPROM and On-Chip Flash
  6. 3 Overview
    1. 3.1 Basic Concepts
    2. 3.2 Single-Unit Method
    3. 3.3 Ping-Pong Method
    4. 3.4 Creating EEPROM Sections (Pages) and Page Identification
  7. 4 Software Description
    1. 4.1 Software Functionality and Flow
  8. 5 Single-Unit Emulation
    1. 5.1 User Configuration
      1. 5.1.1 EEPROM_Config.h
      2. 5.1.2 F29H85x_EEPROM.c
    2. 5.2 EEPROM Functions
      1. 5.2.1 Initialization and Setup Functions
        1. 5.2.1.1 Configure_Device
        2. 5.2.1.2 EEPROM_Config_Check
      2. 5.2.2 Page Mode Functions
        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-Bit Mode Functions
        1. 5.2.3.1 EEPROM_64_Bit_Mode_Check_EOS
        2. 5.2.3.2 EEPROM_Write_64_Bits
      4. 5.2.4 Functions Used in Both Modes
        1. 5.2.4.1 EEPROM_Erase
        2. 5.2.4.2 EEPROM_Read
      5. 5.2.5 Utility Functions
        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 Testing Example
  9. 6 Ping-Pong Emulation
    1. 6.1 User-Configuration
      1. 6.1.1 EEPROM_PingPong_Config.h
      2. 6.1.2 F29H85x_EEPROM_PingPong.c
    2. 6.2 EEPROM Functions
      1. 6.2.1 Initialization and Setup Functions
        1. 6.2.1.1 Configure_Device
        2. 6.2.1.2 EEPROM_Config_Check
      2. 6.2.2 Page Mode Functions
        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-Bit Mode Functions
        1. 6.2.3.1 EEPROM_64_Bit_Mode_Check_EOS
        2. 6.2.3.2 EEPROM_Write_64_Bits
      4. 6.2.4 Functions Used in Both Modes
        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 Utility Functions
        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 Testing Example
  10. 7 Application Integration
  11. 8 Flash API
    1. 8.1 Flash API Checklist
      1. 8.1.1 Flash API Do's and Do Not's
  12. 9 Source File Listing
  13. 10Troubleshooting
    1. 10.1 General
  14. 11Conclusion
  15. 12References

Erase_Bank

The Erase_Bank function leverages the Flash API to erase a full EEPROM Unit. This function is only a wrapper around Flash API, and the protection masks are set in the EEPROM_Erase() functions.

It begins by clearing the FSM status and copying the protection masks into Flash 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);

Then, it erases the flash and checks for programming errors.

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();
}

Finally, if Erase_Blank_Check is set, a blank check is performed.

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();
    }
}