AN1502
APPLICATION NOTE
EMULATED DATA EEPROM WITH ST7 HDFLASH MEMORY
by Microcontroller Division Applications
INTRODUCTION
When the data EEPROM is not available in a ST7 device, it can be emulated by the HDFlash memory with some restrictions. This Application Note describes how to emulate this feature with a ST72F521 device and the restrictions this emulation implies.
Data EEPROM can be emulated in all HDFlash devices.
AS HDFlash is a dual voltage FLASH memory, the 12-volt programming voltage must be provided on the application board (a pull-down on ICPSEL on the application board is advised).
For more information concerning ST7 programming, a .zip file is included with the complete corresponding code for the ST72F521, visit our web site at www.st.com.
AN1502/0202 |
1/7 |
EMULATED DATA EEPROM WITH ST7 HDFLASH MEMORY
1 PRINCIPLE
Two different implementations can be distinguished:
■Assuming that it is possible to limit the data EEPROM byte values to 00h..FEh (as FFh is the default HDFlash erased value), the principle of this emulation is to reserve n bytes in the HDFlash for each emulated data EEPROM byte which has to be cycled n times. With this solution FFh value can not be used.
As shown in Figure 1., a “ptr” pointer gives the access to the emulated data EEPROM byte.
–For a read operation, from “ptr” address, read the first data byte not equal to FFh to get the current value.
–For a write operation, from “ptr” address, look for the last data byte equal to FFh and then write the new value at this location using the HDFlash “Byte programming” Embedded Command (same as IAP method).
Figure 1. HDFlash Emulated Data EEPROM (value in 00h..FEh)
|
|
|
|
|
|
|
|
|
|
current value |
||||
INITIAL STATE |
ptr |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
FFh |
FFh |
... |
FFh |
FFh |
... |
FFh |
val1 |
|
initial value |
|||
|
|
|||||||||||||
mth STATE |
ptr |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
FFh |
FFh |
... |
FFh |
valm |
... |
val2 |
val1 |
|
|
|||
|
|
|
current value
■Assuming no limitation for the data EEPROM byte values (00h..FFh), each byte value will need 2 byte locations. The first one will determine if it is the current value (example: 00h = current value, FFh = not yet used value) and the second one will contain the current byte value. So the principle of this emulation is to reserve 2xn bytes in the HDFlash for each emulated data EEPROM byte which has to be cycled n times.
As shown in Figure 2., a “ptr” pointer gives the access to the emulated data EEPROM byte.
–For a read operation, from “ptr” address, read the first data byte not equal to FFh (equal to 00h), the current value is the next adjacent byte.
–For a write operation, from “ptr” address, look for the last data byte equal to FFh and then write the new value at this location and 00h in the previous location using the HDFlash “Byte programming” Embedded Command (same as IAP method).
In both methods, the programming is address decreasing, which means that when cu.0rrent value is found, the next byte to be programmed is the previous one (refer to diagrams).
In the case of the ST72F521R9 (biggest product) for instance, that means that if sectors 2 and 1 are empty (FFh), the first programmed byte will be at the last address of the sector 1 (EFFFh), because F000h is the first address of the sector 0 containing the user program (this sector is write protected in user mode).
2/7
EMULATED DATA EEPROM WITH ST7 HDFLASH MEMORY
Figure 2. HDFlash Emulated Data EEPROM (value in 00h..FFh)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
current value |
|||||||
INITIAL STATE |
ptr |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
FFh |
|
FFh |
... |
|
FFh |
|
FFh |
|
FFh |
|
FFh |
FFh |
|
FFh |
00h |
|
|
val1 |
|
|||||
|
|
|
|
|
|
|
|
|
|
|||||||||||||||||
|
|
|
||||||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mth STATE |
ptr |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initial value |
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
FFh |
|
... |
FFh |
|
FFh |
00h |
|
valm |
... |
00h |
|
val2 |
00h |
|
|
|
val1 |
|
||||||
|
|
|
|
|
|
|||||||||||||||||||||
|
|
|
|
|||||||||||||||||||||||
|
|
|
|
|
|
current value
2 RESTRICTIONS
■Only a few data EEPROM bytes with a limited number of write/erase cycles can be emulated (these characteristics are directly linked to the needed memory space in HDFlash)
■Emulated data EEPROM must be located in sector 1 or 2 as sector 0 is write protected in USER mode.
–To use the Embedded Commands the RASS protection must be disabled. So the protection against unintentional access to the HDFlash control register is no longer available. Unintentional programming is only guaranteed by the low probability of accidentally executing an Embedded Command with VPP at 12 volts.
3 ADVANTAGE
■ The HDFlash emulated data EEPROM method can keep the data byte value history.
3/7