EEPROMs (Electrically Erasable Programmable Read-Only Memory) are often used in
industrial applications to store updateable data. An EEPROM is a type of permanent (nonvolatile) memory storage system used in complex systems (such as computers) and other
electronic devices to store and retain small amounts of data in the event of power failure.
For low-cost purposes, an external EEPROM can be replaced by an on-chip Flash, with a
specific software algorithm.
This application note describes the software solution for substituting a standalone EEPROM
by emulating the EEPROM mechanism using the on-chip Flash of STM32F0xx devices.
The emulation is achieved by employing at least two pages in the Flash. The EEPROM
emulation code swaps data between the pages as they become filled, in a manner that is
transparent to the user.
The EEPROM emulation driver supplied with this application note meets the following
requirements:
●Lightweight implementations offering a simple API that consists of three functions for
initialization, read data and write data, and reduced footprint.
●Simple and easily updateable code model
●Clean-up and internal data management transparent to the user
●Background page erase
●At least two Flash memory pages to be used, more if possible for wear leveling
May 2012Doc ID 022893 Rev 11/19
www.st.com
ContentsAN4061
Contents
1Main differences between external and emulated EEPROM . . . . . . . . . 5
AN4061Main differences between external and emulated EEPROM
1 Main differences between external and emulated
EEPROM
The EEPROM is a key component of many embedded applications that require non-volatile
storage of data updated with byte or word granularity during run time.
Microcontrollers used in these systems are more often based on embedded Flash memory.
To eliminate components, save PCB space and reduce system cost, the STM32F0xx Flash
memory may be used instead of an external EEPROM for simultaneous code and data
storage.
Unlike Flash memory, however, the external EEPROM does not require an erase operation
to free up space before data can be rewritten. Special software management is required to
store data in an embedded Flash memory.
The emulation software scheme depends on many factors, including the EEPROM reliability,
the architecture of the Flash memory used, and the product requirements.
The main differences between an embedded Flash memory and an external serial
EEPROM are the same for any microcontroller that uses the same Flash memory
technology (it is not specific to the STM32F0xx family products). The major differences are
summarized in Ta bl e 1 .
Table 1.Differences between external and emulated EEPROM
External EEPROM
Feature
Write time
Erase timeN/APage Erase time: from 20 ms to 40 ms
Write method
Read access
Write/Erase cycles1 million Write cycles
(for example, M24C64:
I²C serial access EEPROM)
– Random byte Write within 5 ms.
Word program time = 20 ms
– Page (32 bytes) Write within 5
ms. Word program time = 625 µs
– Once started, is not CPU-
dependent
– Only needs proper supply
– Serial: a hundred µs
– Random word: 92 µs
– Page: 22.5 µs per byte
Half-word program time: from 124 µs to 26 ms
Once started, is CPU-dependent.
If a Write operation is interrupted by software reset,
the EEPROM Emulation algorithm is stopped, but
current Flash write operation is not interrupted by a
software reset.
Can be accessed as half words (16 bits) or full
words (32 bits).
Parallel: (at 48 MHz) the access time by half-word is
from 3.8 µs to 110 µs
10 kilocycles by page. Using multiple on-chip Flash
memory pages is equivalent to increasing the
number of write cycles. See Section 3.4: Cycling
capability and page allocation.
Emulated EEPROM using
on-chip Flash memory
(2)
(1)
(2
1. For further detail, refer to Chapter 2.5: EEPROM emulation timing.
2. For further detail, refer to “Memory characteristics” in STM32F051xx Datasheet.
Doc ID 022893 Rev 15/19
Main differences between external and emulated EEPROMAN4061
1.1 Difference in write access time
Because Flash memories have a shorter write access time, critical parameters can be
stored faster in the emulated EEPROM than in an external serial EEPROM, thereby
improving data storage.
1.2 Difference in erase time
The difference in erase time is the other major difference between a standalone EEPROM
and an emulated EEPROM using embedded Flash memory. Unlike Flash memories,
EEPROMs do not require an erase operation to free up space before writing to them. This
means that some form of software management is required to store data in a Flash memory.
Moreover, as the erase process of a block in the Flash memory does not take long, power
shutdown and other spurious events that might interrupt the erase process (a reset, for
example) should be considered when designing the Flash memory management software.
To design robust Flash memory management software, a thorough understanding of the
Flash memory erase process is necessary.
Note:In case of a software reset, ongoing page erase or mass erase operations on the
STM32F0xx embedded Flash are not interrupted.
1.3 Similarity in writing method
One of the similarities between external EEPROM and emulated EEPROM with the
STM32F0xx embedded Flash is the writing method.
●Standalone external EEPROM: once started by the CPU, the writing of a word cannot
be interrupted by a software reset. Only a supply failure will interrupt the write process,
so properly sizing the decoupling capacitors can secure the complete writing process
inside a standalone EEPROM.
●Emulated EEPROM using embedded Flash memory: once started by the CPU, the
write process can be interrupted by a power failure. In case of a software reset,
ongoing word write operation on the STM32F0xx embedded Flash is not interrupted.
The EEPROM algorithm is stopped, but the current Flash word write operation is not
interrupted by a software reset.
6/19Doc ID 022893 Rev 1
Loading...
+ 13 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.