English
Language : 

AN2540 Datasheet, PDF (14/25 Pages) STMicroelectronics – EEPROM emulation in STR91xFxx devices
Implementing the EEPROM emulation
AN2540 - Application note
Table 7. EepromSectorTransfer
Function Name
EepromSectorTransfer
Function Prototype
u8 EepromSectorTransfer(u8 index, u32 *T, u16 data);
Behavior Description
It transfers the most recent data (Last variable updates) plus the new
data from a full sector to an empty one.
Input Parameter
– index: variable identifier (0, 1, 2...)
– T: variable array
– data: 16-bit data to be written
Return Parameter
Returns 1 on success or error code on failure
Called functions
FindValidSector,FMI_WriteHalfWord, WriteVerifyVariableFull,
ReadVariable, FMI_EraseSector.
At the beginning, the function determines the active sector which is the sector to be
transferred from. The new sector header field is defined and written (new sector status is
RECEIVE_DATA given that it is in the process of receiving data). When the data transfer is
complete, the new sector header is marked VALID_SECTOR and the old one
TRANSFER_COMPLETE. At the end, the old sector is erased.
3.2.2.2 Key features of the 1st method
– User-configured emulated EEPROM size.
– The number of Flash program/erase cycles used can be minimized by permanently
allocating a large memory space to the most frequently updated non-volatile data
variables.
– ReadVariable and WriteVariable functions to access variables.
– The whole available memory space is used to store data: no need for virtual
addresses.
– Fast read access to any variable since this simply implies going to the corresponding
allocated memory space.
– Interrupt servicing during program/erase is possible.
14/25