SPRADL4 January   2025 F29H850TU , F29H859TU-Q1

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. Introduction
  5. Differences Between EEPROM and On-Chip Flash
  6. 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. Software Description
    1. 4.1 Software Functionality and Flow
  8. 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. 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. Application Integration
  11. Flash API
    1. 8.1 Flash API Checklist
      1. 8.1.1 Flash API Do's and Do Not's
  12. Source File Listing
  13. 10Troubleshooting
    1. 10.1 General
  14. 11Conclusion
  15. 12References

EEPROM_Config_Check

The EEPROM_Config_Check() function provides general error-checking and configures Write/Erase protection masks required by the Flash API. This function should be called before programming or reading from the emulated EEPROM Unit(s).

First, the function verifies that the Flash Bank selected for EEPROM Emulation is valid. Only the data bank is a valid selection on F29x.

if (FLASH_BANK_SELECT != C29FlashBankFR4RP0StartAddress)
{
    return 0xFFFF;
}

Second, the validity of Flash Sectors selected for emulation is examined. This function checks for:

  • FIRST_AND_LAST_SECTOR indicating two different numbers of Flash Sectors between the two units
    uint32_t NUM_EEPROM_SECTORS_1 = FIRST_AND_LAST_SECTOR[0][1] - FIRST_AND_LAST_SECTOR[0][0] + 1;
    uint32_t NUM_EEPROM_SECTORS_2 = FIRST_AND_LAST_SECTOR[1][1] - FIRST_AND_LAST_SECTOR[1][0] + 1;
    
    if (NUM_EEPROM_SECTORS_1 != NUM_EEPROM_SECTORS_2)
    {
        return 0xEEEE;
    }
  • More Flash Sectors selected for emulation than available within the Flash Bank
    if (NUM_EEPROM_SECTORS > NUM_FLASH_SECTORS || NUM_EEPROM_SECTORS == 0)
    {
        return 0xEEEE;
    }
  • Invalid combinations for First and Last Sectors selected for emulation
    if (NUM_EEPROM_SECTORS > 1)
    {
        if (FIRST_AND_LAST_SECTOR[0][1] <= FIRST_AND_LAST_SECTOR[0][0])
        {
            return 0xEEEE;
        }
    
        if (FIRST_AND_LAST_SECTOR[1][1] <= FIRST_AND_LAST_SECTOR[1][0])
        {
            return 0xEEEE;
        }
    
        if (FIRST_AND_LAST_SECTOR[0][1] > NUM_FLASH_SECTORS - 1 || FIRST_AND_LAST_SECTOR[0][1] < 1)
        {
            return 0xEEEE;
        }
    
        if (FIRST_AND_LAST_SECTOR[1][1] > NUM_FLASH_SECTORS - 1 || FIRST_AND_LAST_SECTOR[1][1] < 1)
        {
            return 0xEEEE;
        }
    }
    else if (FIRST_AND_LAST_SECTOR[0][0] > NUM_FLASH_SECTORS - 1 ||
             FIRST_AND_LAST_SECTOR[1][0] > NUM_FLASH_SECTORS - 1)
    {
            return 0xEEEE;
    }
  • Overlapping Sectors between the two units
if (FIRST_AND_LAST_SECTOR[0][0] <= FIRST_AND_LAST_SECTOR[1][1] &&
    FIRST_AND_LAST_SECTOR[1][0] <= FIRST_AND_LAST_SECTOR[0][1])
{ 
    return 0xEEEE; 
}
  • If using Page Mode, check if total size of EEPROM Banks + Pages will fit in the Flash Sectors selected.
    Bank_Size = WRITE_SIZE_BYTES*2 + 
                ((EEPROM_PAGE_DATA_SIZE + WRITE_SIZE_BYTES*2) * NUM_EEPROM_PAGES);
    
    uint32_t Available_Words = NUM_EEPROM_SECTORS * FLASH_SECTOR_SIZE;
    
    if (Bank_Size * NUM_EEPROM_BANKS > Available_Words)
    {
        return 0xCCCC;
    }
  • Verify that the two EEPROM units do not have overlapping protection masks
    uint64_t WE_Protection_AB_Sectors_Unit_0 = Configure_Protection_Masks(FIRST_AND_LAST_SECTOR[0], 
                                                                        NUM_EEPROM_SECTORS);
    uint64_t WE_Protection_AB_Sectors_Unit_1 = Configure_Protection_Masks(FIRST_AND_LAST_SECTOR[1], 
                                                                        NUM_EEPROM_SECTORS);
    if (WE_Protection_AB_Sectors_Unit_0 & WE_Protection_AB_Sectors_Unit_1)
    {
        return 0xEEEE;
    }
    

If one of the following nonfatal conditions is detected, a warning is issued. Each flag corresponds to a bit in the return value of the function:

  • Space for one or more EEPROM Banks is left in Flash after configuring EEPROM Bank and Page size
    if (Available_Words - (Bank_Size * NUM_EEPROM_BANKS ) >= Bank_Size)
    {
        Warning_Flags += 1;
    }
  • If each page consists of less than or equal to 64 bits (8 bytes) (this wastes space as the 64-Bit Mode could be used without the need for Status Codes)
    if (EEPROM_PAGE_DATA_SIZE <= WRITE_SIZE_BYTES)
    {
        Warning_Flags += 2;
    }

If using sectors in the 32-127 range (for F29H85x devices) and not using all eight sectors allocated to a single bit in the Write/Erase Protection Mask, a warning is issued. Any unused sectors within the eight designed by a single bit cannot be properly be protected from erase. For more information on how the Write/Erase Protection Masks correspond to sectors, see the F29H85x Flash API Reference Guide

uint8_t i;
for (i = 0; i < 2; i++)
{
    // If using any sectors > 31
    if (FIRST_AND_LAST_SECTOR[i][1] > 31)
    {
        // If all sectors are > 31 (use protection mask B)
        if (FIRST_AND_LAST_SECTOR[i][0] > 31)
        {
            // If using < 8 sectors (will be clearing more than necessary)
            if (NUM_EEPROM_SECTORS < 8)
            {
                Warning_Flags += 4;
                break;
            }
            // if sector isn't a multiple of 8 (will be clearing more than necessary)
            else if ((FIRST_AND_LAST_SECTOR[i][0] % 8) != 0 ||
                     (FIRST_AND_LAST_SECTOR[i][1] + 1) % 8 != 0)
            {
                Warning_Flags += 4;
                break;
            }
        }
        // if sector isn't a multiple of 8 (will be clearing more than necessary)
        else if ((FIRST_AND_LAST_SECTOR[i][1] + 1) % 8 != 0)
        {
            Warning_Flags += 4;
            break;
        }
    }
}