External EEPROMs are often used in applications to store data that may be later updated or
adjusted. On the other hand, the microcontrollers used in these systems are based more and
more on embedded Flash.
The trend to continuously reduce the number of components is forcing designers to look to use
Flash memory to emulate EEPROM.
This application note explains the differences between external EEPROMs and embeddedFlash and gives advice on how to substitute external EEPROM to emulated-EEPROM using
the on-chip Flash of STR71xF devices.
Although the concept is easy to explain and implement “as is”, there are some embedded aspects that have to be taken into account.
Substituting external EEPROM with emulated EEPROM from the embedded-Flash of the microcontroller is a complex development. This application note assumes that readers are already familiar with the techniques used to secure the content of evolutive information in external EEPROM of embedded applications.
This application note is organized in 4 parts:
– Description of the differences between external EEPROMs and embedded-Flash,
– General description of EEPROM emulation concept,
– Introduction to embedded application aspects,
– Software example.
Although this application note is mainly refers to STR710FZ1, STR710FZ2, STR711FR1,
STR711FR2, STR712FR2 and STR712FR2,
crocontroller.
Before describing the proposed concept for EEPROM emulation, it is important to bear in mind
the main differences between the embedded-Flash memory of a microcontroller and serial ex
ternal EEPROMs. These differences apply to any microcontroller (i.e. not specific to STR71xF
variants). They are summarized in the table below.
Table 1. Differences between Embedded Flash and EEPROM
-
FeatureEEPROM
several ms
Write time
Erase timeN/A
Write method
Write access
random byte: 5 to 10ms
page: equivalent to hundred µs / word (5 to
10ms per page)
once started, is not CPU-dependent;
needs only proper supply.
serial: hundred µs
random word: 92µs
page: 22.5µs /byte
Emulated EEPROM from Embedded-
Flash
several µs
(ex: 16µs per word)
seconds
(ex: 1.5s)
once started, is CPU-dependent: a CPU
reset will stop the write process even if
supply stays within specification.
parallel: hundred ns
a small number of CPU cycles per word.
1.1 DIFFERENCE IN WRITE ACCESS TIME
As Flash has a shorter write access time, critical parameters can be stored faster in the emulated EEPROM than in a serial external EEPROM, thereby improving the robustness of the
system if the same safety concept is kept.
1.2 DIFFERENCE IN WRITING METHOD
One of the important differences between external EEPROM and emulated EEPROM for embedded applications is the writing method.
– Stand-alone external EEPROM: once started by the CPU, the writing of a word cannot be
interrupted by a CPU reset. Only supply failure will interrupt the writing process; so properly
sizing the decoupling capacitors can secure the complete writing process inside a standalone EEPROM.
– Emulated EEPROM from an embedded-Flash: once started by the CPU, the writing can
be interrupted by a power failure and by a CPU reset.
This difference should be analysed by system designers to understand the possible impact(s)
on their applications and to define the proper handling method.
3/19
EEPROM Emulation with STR71x
1.3 DIFFERENCE IN ERASE TIME
The difference in erase time is the other important difference between stand-alone EEPROMs
and emulated EEPROM with embedded-Flash. Unlike Flash, EEPROM does not require a
block erase operation to free-up space before write. This means that some form of software
management is required to store data in Flash. Moreover, as the erase process of a block in
the Flash takes few seconds, power shut-down and other spurious events that may interrupt
the erase process (ex: reset) should be considered when designing the Flash management
software. This means that to design a robust Flash management software it is necessary to
have a deep understanding of the Flash erase process.
The Flash erase process is split in 3 phases:
– phase1: write all bits to 0, starting from the initial content. An interrupt during this phase will
result in some memory cells being at “0” logic level and the rest of the memory cells will still
contain their initial content.
– phase2: write all bits to 1, starting from the all “0” configuration. The longer the time before
this phase is interrupted, the higher the number of cells will return a “1” logic level. The rest
of the memory cells will contain their initial content, their content can be considered as totally
random.
– phase3: equalization. This phase is necessary to recover over-erased cells. The Flash man-
agement software for EEPROM emulation should guarantee that this phase was successfully completed before programming in this bank.
The consequence of an interrupt during phase2 is that a single bit approach should be avoided
to flag the completion of the erasing process (find more details in
section 2.5 on page 6).
The consequence of an interrupt during phase1 and/or phase2 is that it is recommended to
have fixed data inside the emulated EEPROM so that a checksum can be run to tell which
Flash bank keeps the valid data.
The most important point is to ensure that the Flash has been completely erased (phase3 was
not interrupted) before programming data inside a bank.
Note The design of Flash software management is easier if programming in a new bank is always made
just after erasing of this bank (when erasing of one bank is necessary).
1.4 ADDITIONAL INFORMATION ON FLASH
Incremental programming: the Flash controller will accept to program a word that is already
programmed if the new word is adding more “0” bits.
Programming completion: programming completion is important to guarantee data retention
time; the programming is complete when the Flash controller status indicates the end of pro
gramming without showing any error flag. If programming is interrupted (ex: supply fail, CPU
reset), the cells of the word being programmed will be partially programmed. This can result in
unstable “0”s when reading this word.
-
4/19
EEPROM Emulation with STR71x
2 EEPROM EMULATION CONCEPT
2.1 PRINCIPLE
Different concepts are described in the literature. Each of them rely on partitioning a bank of
the Flash into several Data-sets and on using control bits (per Flash bank and per Data-set) to
compute which Flash bank and which Data-set is the valid one. For variable-length Data-sets,
linked data-list structures should be considered.
The method described in this document is based on fixed-length Data-sets and 2 Flash banks.
Figure 1. Bank partitioning for emulated EEPOM
Area for Data-set storage
Status bits for
Data-set-n
Area for status bit storage
(Data-set bits and
Flash bank bits)
STR71x Flash Bank-x
Data-set-n
Data-set-2
Data-set-1
Data-set-0
n
12
0
Switch between each bank
(Erase one when using the other)
STR71x Flash Bank-y
Data-set-m
Data-set-2
Data-set-1
Data-set-0
m
12
0
Variable update frequency
The variable update frequency may set high requirements on the program/erase cycle of the
Flash and on the Flash features (ex: Read-While-Write). Those features are analysed in detail
in the following pages.
5/19
EEPROM Emulation with STR71x
2.2 PROGRAM/ERASE CYCLE
The requirement number of program/erase cycles is computed by dividing the needed number
of erase cycles by the total number of Data-sets in the Flash banks (for example in
Figure 1:
n+m). When this number is still higher than the Flash write/erase endurance characteristics, a
closer analysis is needed to understand when the Data-sets are updated:
– When Data-sets need to be updated during operation, it is proposed to use a buffer in RAM
and to save the data before shutting-down the microcontroller.
– When Data-sets are updated only before a power-down sequence, it is proposed to increase
the size of the Flash bank or to use a 3rd bank (see additional information in
Section 3).
2.3 READ-WHILE-WRITE
Most currently available Flash technologies must complete a program or erase operation before code or data can be read from another memory block. There is a common misconception
that EEPROM emulation can only be done when Read-While-Write functionality is imple
mented. Read-While-Write, when present, allows other memory blocks to be accessed during
erasing and programming; this means that the CPU program does not need to be copied into
RAM during programming/erasing. Read-While-Write does not prevent having a RAM buffer if
access into the emulated-EEPROM is needed during programming.
-
When Read-While-Write is not supported, program or erase suspend command can be used
to temporarily read code. All STR71xF variants support program and erase suspend com
mands.
2.4 FLASH ORGANIZATION
The concept described above shows the Flash bank split into 2 parts:
– Data-set storage: which keeps all variable information,
– Status bit storage: which keeps status of the Flash bank and of the Data-sets.
Other organizations are possible (ex: to include the Data-set status bits inside each Data-set)
for which users may see advantages for their application.
2.5 DATA-SET STATUS BITS
Two status bits are proposed for each Data-set with the combinations shown in the following
table.
-
6/19
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.