cancel
Showing results for 
Search instead for 
Did you mean: 

HI ALL. In Our project with STM32F103 we're using FLASH as EEPROM. with reffering to "AN2594 Application note EEPROM emulation in STM32F10x microcontrollers".

MSm
Associate II

in some cases that we encountered, 2 types of failure occur. 

1- when powering up, ALL sectors of flash, are Erased. we guess ESD makes all sectors erased. with additional protection in power circuit, this problem solved.

2- after powering up, we realized that 2 sectors which used as eeprom, are Erased. (not all sectors containing program). in other words, program works properly but saved data does not exist anymore.

As I saw in mentioned Application Note at above, section 3.3 "Page header recovery in case of power loss" according table 2, "three of which are invalid" . with refer to "eeprom.c" in ST's Example (we use this APIs), I understood according to this document, in this 3 states 2 flash sectors that used as eeprom, will format.

"/* Invalid state -> format eeprom */"

can anyone says how to handle this problem. should we use POR or PDR? HOW?

and about my first question? Is there any advices ?

thanks.

1 REPLY 1

I'm not an advocate of EEPROM Emulation, but as asked to respond, here are my thoughts.

Don't use EEPROM Emulation, understand how the underlying FLASH works, and how to hold and partition your data better.

For permanent/semi-permanent stuff use OTP and FLASH areas separate from your other data.

Have Workable Defaults.

Do not unlock the flash to read the data.

Push your data in a structure, in one place, avoid having a million global variables, and copying them individual.

Journal the structure across multiple sectors/pages.

Have a checksum/crc on the data, and a sequence number.

Copy the whole structure to RAM, and work on RAM copy.

Only erase when all memory is close to being consumed, and always erase the least recently used sector.

Plan when memory is getting low, don't make it occur under critical conditions.

Don't rush to unlock/erase at startup, do it when you are reasonably sure things are stable.

Perhaps schedule for two minutes after power-up.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..