• Menu
  • Product
  • Email
  • PDF
  • Order now
  • undefined

    • SPRADE8 November   2023 TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DH-Q1 , TMS320F28P659DK-Q1 , TMS320F28P659SH-Q1

       

  • CONTENTS
  • SEARCH
  • undefined
  1.   EEPROM Emulation for Generation 3 C2000 Real Time Controllers
  2.   Trademarks
  3. 1 Introduction
  4. 2 Difference Between EEPROM and On-Chip Flash
  5. 3 Overview
    1. 3.1 Basic Concept
    2. 3.2 Single-Unit Method
    3. 3.3 Ping-Pong Method
    4. 3.4 Creating EEPROM Sections (Pages) and Page Identification
  6. 4 Software Description
    1. 4.1 Software Functionality and Flow
  7. 5 Ping-Pong Emulation
    1. 5.1 User-Configuration
      1. 5.1.1 EEPROM_Config.h
      2. 5.1.2 F28P65x_EEPROM.c
    2. 5.2 EEPROM Functions
      1. 5.2.1  EEPROM_Config_Check
      2. 5.2.2  Configure_Protection_Masks
      3. 5.2.3  EEPROM_Write
      4. 5.2.4  EEPROM_Read
      5. 5.2.5  EEPROM_Erase
        1. 5.2.5.1 Erase_Bank
      6. 5.2.6  EEPROM_GetValidBank
      7. 5.2.7  EEPROM_UpdateBankStatus
      8. 5.2.8  EEPROM_UpdatePageStatus
      9. 5.2.9  EEPROM_Get_64_Bit_Data_Address
      10. 5.2.10 EEPROM_Program_64_Bits
      11. 5.2.11 EEPROM_CheckStatus
      12. 5.2.12 ClearFSMStatus
    3. 5.3 Testing Example
  8. 6 Single-Unit Emulation
    1. 6.1 User-Configuration
      1. 6.1.1 EEPROM_Config.h
      2. 6.1.2 F28P65x_EEPROM.c
    2. 6.2 EEPROM Functions
      1. 6.2.1  EEPROM_Config_Check
      2. 6.2.2  Configure_Protection_Masks
      3. 6.2.3  EEPROM_Write
      4. 6.2.4  EEPROM_Erase
      5. 6.2.5  EEPROM_GetValidBank
      6. 6.2.6  EEPROM_Get_64_Bit_Data_Address
      7. 6.2.7  EEPROM_UpdateBankStatus
      8. 6.2.8  EEPROM_UpdatePageStatus
      9. 6.2.9  EEPROM_Get_64_Bit_Data_Address
      10. 6.2.10 EEPROM_Program_64_Bits
      11. 6.2.11 EEPROM_CheckStatus
      12. 6.2.12 ClearFSMStatus
    3. 6.3 Testing Example
  9. 7 Application Integration
  10. 8 Adapting to Other Gen 3 C2000 MCUs
  11. 9 Flash API
    1. 9.1 Flash API Checklist
      1. 9.1.1 Flash API Do's and Do Not's
  12. 10Source File Listing
  13. 11Conclusion
  14. 12References
  15. IMPORTANT NOTICE
search No matches found.
  • Full reading width
    • Full reading width
    • Comfortable reading width
    • Expanded reading width
  • Card for each section
  • Card with all content

 

Abstract

EEPROM Emulation for Generation 3 C2000 Real Time Controllers

Many applications require storing small quantities of system related data (calibration values, device configuration) in non-volatile memory so that it can be used or modified and reused even after power cycling the system. Electrically erasable programmable read-only memory, or EEPROM, is primarily used for this purpose. EEPROMs have the ability to erase and write individual bytes of memory many times over and the programmed locations retain the data over a long period even when the system is powered down. This application report and the associated code help to define a sector(s) of on-chip Flash memory as the emulated EEPROM and is transparently used by the application program for writing, reading, and modifying the data.

Project collateral and source code discussed in this application report can be found in C2000Ware v5.01.00.00 (or higher) at the following path: C2000Ware_5_01_00_00/driverlib/f28p65x/examples/c28x/flash/.

Trademarks

All trademarks are the property of their respective owners.

1 Introduction

Generation 3 C2000 MCUs come with different configurations of Flash memory that is arranged in multiple sectors. Unfortunately, the technology used for the on-chip Flash memory does not allow adding a traditional EEPROM on the chip. Some designers use an external EEPROM part for such non-volatile storage. The good news is that Flash memory is a specific type of EEPROM and all Generation 3 C2000 MCUs have in-circuit programming ability for the Flash memory. This application report makes use of this facility and allows using sectors of on-chip Flash as EEPROM by emulating the EEPROM functionality within the limitations of the Flash memory. Note that at least one Flash sector is entirely used as an emulated EEPROM; therefore, it is not available for the application code.

Note: Generation 3 C2000 MCUs include: TMS320F2837x, TMS320F2838x, TMS320F28004x, TMS320F28002x, TMS320F28P65x, TMS320F280013x, TMS320F280015x.

2 Difference Between EEPROM and On-Chip Flash

EEPROMs are available in different capacities and connect with the host microcontrollers via a serial and sometimes parallel interface. The serial inter-integrated circuit (I2C) and serial peripheral interface (SPI) are quite popular due to the minimal number of pins/traces. EEPROMs can be programmed and erased electrically and most of the serial EEPROMs allow byte-by-byte program or erase operations.

The major difference between EEPROM and Flash operations is seen in the erase operation. The EEPROM does not require a sector erase operation. One can erase a particular byte requiring the specified time. However, the smallest unit of an erase operation in Flash is one sector.

Flash erase and write cycles are performed by applying time-controlled voltages to each cell. In the erase condition, each cell (bit) reads logical 1. Therefore, every Flash location of a C2000 Real-Time Controller reads 0xFFFF when erased. Through programming, the cell can be changed to logical 0. Any word can be overwritten to change a bit from logical 1 to 0 (assuming corresponding ECC has not been programmed); but not the other way around. The on-chip Flash memory on Generation 3 C2000 MCUs parts require TI-supplied specific algorithms (Flash API) for erase and write operations.

Note: For the Flash erase/program/read times, see the Flash Parameters section in Electrical Characteristics of the device-specific data manual.

3 Overview

The implementation described in this document supports both Single-Unit and Ping-Pong EEPROM Emulation. Single-Unit and Ping-Pong implementations both support two modes, Page-Programming and 64-Bit Programming mode. Ping-Pong Emulation will be described first, and Single-Unit will be described subsequently.

There are multiple user-configurable EEPROM variables supported by this implementation. These variables are detailed in Section 5.1.

3.1 Basic Concept

In this implementation, the emulated EEPROM is comprised of at least one Flash Sector. Due to the block erase requirement of Flash, a Flash sector has to be entirely reserved for the EEPROM Emulation. Based on the C2000 part number, the size of the Flash sector will vary. The area of the Flash sector is divided into a number of smaller sections and is referred to as a Page. For example, a 2K x 16 flash sector can be divided into 32 pages, each with a size of 64 x 16.

The data to be saved is first written in a buffer in RAM. Then, using the in-circuit programming facility of Generation 3 C2000 MCUs, the data is written to the first page in the selected sector(s) for EEPROM Emulation. The next time data is written to Flash, it will be written to the next page. This process continues until the last page in the selected sector is written. Upon reaching the last page, there are two ways to continue. If using Single-Unit EEPROM emulation, see the Single-Unit Emulation behavior to see how this is handled. If using Ping Pong EEPROM Emulation, see Ping-Pong Method to see how this is handled.

In addition to the Page Programming concept described above, there is also support for 64-Bit Programming. In this mode, the sectors is not broken into EEPROM banks and pages. 64-Bit Programming is discussed further in Section 5.2.9 and Section 5.2.10 .

3.2 Single-Unit Method

If using Single-Unit EEPROM Emulation, Figure 3-1 shows the implemented behavior.

GUID-20231019-SS0I-SXXS-BF2X-2SL5BLPFW7HR-low.png Figure 3-1 Single-Unit Behavior

If the EEPROM unit is full and there is more data to be written, the EEPROM unit is erased and the new data is programmed to Flash. This process can be repeated as necessary.

3.3 Ping-Pong Method

If using the Ping Pong method, the following diagram shows the implemented behavior. As shown in Figure 3-2, there are two EEPROM units made up of selected Flash Sectors. One is marked as an Active Unit, and the other is marked as the Inactive Unit. To begin, data is written to the Active Unit.

GUID-20231019-SS0I-KPFS-W2PG-KFWMCHGXL1PQ-low.png Figure 3-2 Ping Pong Behavior

If the Active Unit is full and there is more data to be written, the Active and Inactive EEPROM units will switch. Therefore, the previously Active Unit (full Unit) will be marked as Inactive, and the previously Inactive Unit (empty Unit) will be marked as Active. Subsequently, the data will be written to the newly Active EEPROM Unit. After the data is successfully programmed to the Active EEPROM Unit, the Inactive EEPROM Unit is erased. This method ensures that there is a fall-back options for the last successfully written data in case of any failure during the erase or program operation when the currently active EEPROM Unit is full.

This process can be repeated as necessary.

3.4 Creating EEPROM Sections (Pages) and Page Identification

In order to support EEPROM emulation with varying data sizes (other than 64-bits), the Flash Sectors selected for emulation are divided into a format referred to as EEPROM Banks (not to be confused with Flash Banks) and Pages. First, the Flash sector (or set of chosen Flash Sectors) is divided into EEPROM banks. Each EEPROM bank is further divided into Pages. This partitioning is shown in Bank Partitioning. The partitioning of EEPROM Banks and Pages is the same for Single-Unit and Ping-Pong emulation.

Using this format allows the application to:

  • Read back the data from the page written during the previous save
  • Write the latest data to a new page
  • Read from any previously stored data, if required by the application
GUID-20231004-SS0I-JTKD-2S3T-DKFJDSLT4WZ2-low.png Figure 3-3 Bank Partitioning

The first eight 16-bit words of each EEPROM bank are reserved for EEPROM bank status information and the first eight words of each page are reserved for page status information. Every time a new set of data is written to a page, the status location of the last page and the next page are modified. When a new EEPROM bank is used the Bank Status of the last and current EEPROM banks are updated. Both the EEPROM Bank and Page status words differentiate between the current EEPROM Bank/Page and a used EEPROM Bank/Page in the same way. To mark an EEPROM Bank or Page as current, the first 64-bits are written with the appropriate status code. To mark an EEPROM Bank or Page as full, the latter 64-bits are written with the appropriate status code. More details about the status codes can be found in the EEPROM_GetValidBank.

As seen in Page Layout, all pages contain an eight-word page status and a configurable amount of data space. Page 0 is slightly different as it contains the EEPROM bank status as well. Only Pages 0 and 1 are shown, but it should be noted that Page 2 through Page (N-1) are identical to Page 1.

GUID-20231004-SS0I-MMG4-PHZM-BM0NHPRC0DGB-low.png Figure 3-4 Page Layout

 

Texas Instruments

© Copyright 1995-2025 Texas Instruments Incorporated. All rights reserved.
Submit documentation feedback | IMPORTANT NOTICE | Trademarks | Privacy policy | Cookie policy | Terms of use | Terms of sale