Introduction
EEPROMs (electrically erasable programmable read-only memories) are used for nonvolatile storage of updatable application data, or to retain small amounts of data in the event of power failure in complex systems. To reduce cost, an external EEPROM can be replaced by on-chip flash memory, provided that a specific software algorithm is used.
This application note describes the software solution (X-CUBE-EEPROM) for substituting a standalone EEPROM by emulating the EEPROM mechanism using the on-chip flash memory available on the STM32 series products listed in Table 1. X‑CUBE‑EEPROM also provides a firmware package including examples showing how to exploit this EEPROM emulation driver (see API and application examples).
For STM32WB series products only, an example that maintains a Bluetooth® LE connection and communication while performing EEPROM operations is provided.
For STM32H5 series products, an example using the high-cycle data area for the EEPROM operations is provided.
The emulation method uses at least two flash memory pages, between which the EEPROM emulation code swaps data as they become filled. This is transparent to the user. The EEPROM emulation driver supplied with this application note has the following features:
- Lightweight implementation and reduced footprint.
- A simple API consisting of a few functions to format, initialize, read and write data, and clean up flash memory pages.
- At least two flash memory pages to be used for internal data management.
- Clean-up simplified for the user (background page erase).
- Wear-leveling algorithm to increase emulated EEPROM cycling capability.
- Robust against asynchronous resets and power failures.
- Optional protection implementation for flash memory sharing between cores in multicore STM32 devices (for example STM32WB series).
- Maintenance of cache coherency.
The EEPROM size to be emulated is flexible and only limited by the flash memory size allocated to that purpose.
| Type | Series |
|---|---|
| Microcontrollers | STM32C0 series, STM32G0 series, STM32G4 series, STM32H5 series, STM32L4 series, STM32L4+ series, STM32L5 series, STM32U0 series, STM32U3 series, STM32U5 series, STM32WB series, STM32WL series |
