The ST10F27x MCUs provide 0.18µm embedded true Flash technology.
This Flash technology has been designed to store software program instructions and is not
adapted to dynamic data storage because it can only be erased by sector.
Typically, when the code is programmed, some portions of the Flash remain free. This
unused space can be used as virtual EEPROM, thus avoiding the additional cost and
complexity incurred by using an external serial EEPROM.
This application note shows a method of performing EEPROM emulation. It provides
software routines to overcome the Flash limitations in terms of read/write access and
number of cycles.
This document is divided into the following sections:
■ Overview of ST10F27x Embedded Flash
■ The ST10F27x Flash library provided by STMicroelectronics
■ Application example: EEPROM Emulation. This application example helps the user to
become familiar with the ST10F27x Flash library, given that it uses the main important
Flash library functions of programming, erasing and verifying.
The application source files are provided within an associated downloadable package. This
file must be unpacked into a directory before use.
The EEPROM emulation driver was compiled using the two tool chains, Tasking and Keil,
and it can be ported easily to any other ST10 tool chain.
For more information, please refer to the ST10F27x related documentation.
The ST10F27x provides an on-chip high-speed single voltage Flash memory.
The write operations of the ST10F27x Flash banks are managed by an embedded Flash
Program/Erase Controller.
The following table summarizes the main ST10F27x Embedded Flash characteristics:
ST10F271ST10F272ST10F273ST10F275ST10F276
Flash Size
(KBytes)
Flash Organization
Banks / Sectors
Programming
voltage
Programming
method
Program/Erase
cycles
128256512832832
1 /61 / 82 / 124 /174 /17
5 Volts
Write/Erase Controller
100 Kcycles, 20 years data retention
Depending on the ST10 derivative, the Flash memory will be composed either of 1 module
(IFLASH) or of 2 modules (IFLASH and XFLASH). Each module is divided into several
banks, themselves sub-divided into sectors.
The ST10F276 and ST10F275 embedded Flash is composed of two modules.
The ST10F271, ST10F272 and ST10F273 embedded Flash is composed of one module.
On the IFLASH, the internal data bus is 32 bits wide (I-BUS).
The XFLASH module is mapped on the XBUS and the data bus is 16 bits wide (X-BUS).
The smallest erasable part of Flash is a sector.
3/17
2 The ST10F27x Flash libraryAN2244
2 The ST10F27x Flash library
The Flash programming library is a set of optimized C routines and contains everything
needed to program the embedded Flash of ST10 devices in 0.18µ technology, i.e the
ST10F27x family devices.
The Flash library contains the following source files:
●flash.c, containing the functions’ code
●flash.h, containing the functions’ prototypes
●F27x_flash.h, containing the definitions of the Flash registers and sectors’ size for the
ST10F27x devices Flash
To use the functions provided by the Flash library, these files must be added to the project.
The CPU frequency must be set in F27x_flash.h library file:
#define Fcpu_MHz ((unsigned int) 40)
In order to be able to use the ST10F27x Flash library, the MCU(ST10F27x derivative) and
the toolchain (Tasking or Keil) must be defined and start up configurations must be properly
set up.
For more details about the ST10F27x Flash library and how to use it, please refer to the
"Flash programming for ST10 devices in 0.18um technology" application note.
4/17
AN22443 Application example: EEPROM emulation using ST10F27x Flash library
3 Application example: EEPROM emulation using
ST10F27x Flash library
3.1 Purpose
The purpose of this example is to show how a portion of the ST10F27x embedded Flash
can be used to replace a serial EEPROM to store and update non volatile data in order to
save the cost of an external EEPROM.
3.2 Principle
The implementation shown in this application note requires that a minimum of two Flash
sectors of identical size are allocated to non volatile data storage. In this example, the sector
1 and sector 2, 8 kbytes each, of the Flash bank 0 are used.
Those sectors are write accessed in 32-bit.
A header field occupying the first 32-bit word of each sector represents the sector’s status.
In order to use Flash to store several non volatile variables, we need to divide the two
sectors identically into several parts, one per variable.
For each variable, the size of the memory space is allocated according to its update
frequency. The first 32-bit value of each variable is stored at the base address of its
allocated memory space. When updated, the new value is stored at the next available
address: base address + 4, base address + 8 and so on until no room remains from its
allocated memory.
Example:
In the sector 1, we assume 3 variables: A, B and C will be stored and updated.
The first variable A value is stored at t
0
The second variable B value is stored at t
The third variable C value is stored at t
2
and variable A(t) is updated every
and variable B(t) is updated every
1
and variable C(t) is updated every
t
A
t
B
t
C
In a typical application, the majority of non volatile data is updated infrequently and a few is
updated more frequently.
Let’s consider t
< tB< tC , this means that A is updated more than B which is updated more
A
than C so more memory space should be allocated to A and B than C.
In this application, sector 1 is divided as follows:
●0x2000-0x2FFF memory space will be allocated to variable A
●0x3000-0x3FEB memory space will be allocated to variable B
●0x3FEC-0x3FFF memory space will be allocated to variable C
5/17
3 Application example: EEPROM emulation using ST10F27x Flash libraryAN2244
Figure 1.Variable updates in sector 1
0x3FFF
0x3FF0
0x3FEC
0x3010
0x300C
0x3008
0x3004
0x3000
0x2014
0x2010
0x200C
0x2008
0x2004
0x2000
C(t
+ tC)
2
C( t2 )
B(t1 + m * tB)
.......
.......
B(t
+ 3 * tB)
1
B(t
+ 2* tB)
1
B(t
+ tB)
1
B(
t1 )
A(t
+ n * tA)
0
.......
.......
.......
.......
.......
.......
.......
A(t
+ 3 * tA)
0
+ 2 * tA)
A(t
0
A(t
+ tA)
0
A( t0 )
sector 1 header
sector 1
0x5FFF
0x5FEC
0x5000
0x4000
sector 2 header
sector 2 erased
In sector 1, variables are stored until there is insufficient memory space to allocate to one of
these variables (case of variable A in the example).
Assume that the variable A should be updated at the time t
+ (n+1) * t
0
with A(t
A
+ (n+1) * t
0
).
A
Addresses from 0x2004 to 0x2FFC are all full, the next value is then stored in the base
address of the space allocated to the variable A in the sector 2.
The latest stored value of every other variable (B and C) is transferred from its last location
in sector 1 to the base address of its allocated space in sector 2.
This is illustrated in the Figure 2.
6/17
Loading...
+ 11 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.