English
Language : 

AN2244 Datasheet, PDF (8/17 Pages) STMicroelectronics – The ST10F27x MCUs provide 0.18μm embedded true Flash technology
3 Application example: EEPROM emulation using ST10F27x Flash library
AN2244
3.4
3.4.1
3.4.2
EEPROM software description
This section describes the software implemented for EEPROM emulation using the
ST10F27x Flash library provided by STMicroelectronics.
This example uses the 3 variables A, B and C already defined.
The project contains 3 source files in addition to the three library source files:
● eeprom.c: containing C code for the following project routines
EepromFormat( )
WriteVariable( )
ReadVariable( )
FindValidSector( )
WriteVerifyVariableFull( )
EepromSectorTransfer( )
FlashRead( )
● eeprom.h: containing the routines’ prototypes and some declarations.
● main.c: This application program is an example that uses the routines described in
eeprom.c in order to write and read from the eeprom.
Header field
The header field occupies each sector base address and gives the sector’s status
information. Each sector has four possible states:
● ERASED: This sector is empty.
● RECEIVE_DATA: This sector is receiving data from the full one.
● VALID_SECTOR: This sector contains valid data and this state will not change until
valid data are completely transferred to the erased sector.
● TRANSFER_COMPLETE: Transfer of data to the other sector is finished and this
sector is no longer in use. The system can then erase this sector to prepare it for future
data.
The Figure 3 shows how to switch from one state to another for both sectors.
Variables array
Every variable is defined by its start address in its allocated memory space.
An array of variables is declared and located in the user application as described in
Section 3.4.4
Its size must be defined in the eeprom.h file.
8/17