cancel
Showing results for 
Search instead for 
Did you mean: 

Data even after reset

SARTHAK KELAPURE
Associate II
Posted on December 26, 2017 at 10:51

Hello everyone,

I wish to store a variable in flash memory untouched which will be changed only once but I can read or write it anytime I want, how is that possible? I do not wish to use the ROM unless there is no way around.

Thank you in advance

#stm32-flash-memory #stm-32 #stm32l0
2 REPLIES 2
S.Ma
Principal
Posted on December 26, 2017 at 11:53

A memory which keeps data after reset or power off/on are non volatile memories.

If you want just small amount of data, use EEPROM (electrically erasable ROM).

Some STM32 have built-in EEPROM (STM32L15x), or use an I2C EEPROM. Some of these EEPROM have OTP page (you can write once to prevent accidental erase).

Otherwise, you can use FLASH sectors, sometime emulating EEPROM behaviour.

The corresponding area in FLASH shall be 'excluded' from the linker normal allocatable code space and you'll have to make sure the programmer does not affect this area when debugging or reflashing.

Posted on December 26, 2017 at 18:02

Shrink the memory described to the linker by the size of one flash sector. This sector will then be available at the end of the memory space, and you can erase, write and read that area. Typically one could use a structure, with a signature, and checksum, and you could use a pointer to access the memory, checking for valid content, and writing/using defaults in the absence of valid data.

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