2017-09-04 12:49 AM
Hello,
I'm using a STM32F091VBTx microcontroller and for the application I'm implementing I need a variable to be constantly updated and it must be stored in a non-volatile memory in order to keep its value even if the microcontroller resets. I've found AN2594 about EEPROM emulation, but the functions described there are not available for the microcontroller I'm using. Should I use the functions provided in the stm32f0xx_hal_flash.c file? If yes, I would like to know if there is a demo software for this or if there is any other method to update values in a non-volatile memory. Thanks. #stm32f091vb #variable #non-volatile #memory #eeprom-emulation Note: this post was migrated and contained many threaded conversations, some content may be missing.2017-09-07 04:47 AM
I don't know if that is because the eeprom is electrically different, or because of a wear leveling controller.
Maybe memory mapped SPI flash/eeprom/fram is something ST could consider instead of on-chip eeprom?
2017-09-07 04:55 AM
i never heard about wear-leveling controllers for EEPROM.
memory-mapped SPI flash exists for higer STM32 chips (QSPI to be correct) and it is not allowing WRITE in this mode, only read: to write something you must switch to indirect mode, write your data and then switch to memory-mapped mode.
2017-09-07 05:05 AM
dedicated flash memory array with minimal granularity (8 or 32bit wide) would be useful asset. Shame it doesnt exists in STM32 chips
2017-09-07 05:59 AM
I suggest writing the value(s) at successive locations in a sector. When you startup scan through to the last one. That way you should not need to erase very often. You can adjust the maximum size of flash used so that you stay well below the endurance limit. If you want to use 'ping-pong' sectors then put a sequence number at the start of the log so you know which one is the newest if you detect both of them active at startup.
2017-09-07 06:48 AM
I would refrain from writing single values to Flash.
Instead collect them, and write all in one block.
Perhaps two blocks in ping-pong mode, that would give you a fall-back dataset just in case.
2017-09-07 07:01 AM
Marco - did you get your issue resolved? I did a file compare with the AN4061 version for the F091, against what I am using for our Nucleo-F429- found in projects>stm32f429zi-nucleo>applications>eeprom etc, and the files are different, but the principal entry points for reading and writing your own data seem to be the same. I just implemented ST's eeprom.c in our applications for the F429 this week. A comment from Clive One was useful in terms of a modification to the .LD file. I am not using his comment yet, as the application does not seem to load into the target area used by eeprom.c to date. In any case, read and write, and read at boot time are working so far to implement a 'non-volatile ram' concept. I deliberately do not preserve all of my data tables, just items that are critical, and since these items are user setpoints, they will rarely change, but I want them preserved across power fails. Trying to duplicate the full memory of 128K SRAM being preserved with data being changed at machine speeds which we had on Intel/Innovasic architecture before moving to the Nucleo-F429 is not likely until we implement our own board, or ST improves the Nucleo significantly.
mailto:Dan.Mackie@DrSCADA.com
2017-09-07 08:09 AM
If you do implement saving a critical variable to non-volatile memory, you should also use a checksum,crc or write ones compliment. This way after a power off/on cycle you can detect if the power off occurred during the data write cycle. Small chance of this but I assure you that it will happen sometimes.
2017-09-07 10:35 AM
Dan, I haven't solved the issue yet. I used the `eeprom.c` example shown in `en.stm32cubef0\STM32Cube_FW_F0_V1.8.0\Projects\STM32F091RC-Nucleo\Applications\EEPROM\EEPROM_Emulation` which uses HAL library. I'm trying to keep just one variable by using the `eeprom.h` functions to write the value and I lose the information after a reset or after a power off of the board. I'm checking if maybe I'm using wrong addresses. I have not modified the *.ld file.
2017-09-07 11:32 AM
I am using eeprom.c/.h almost unmodified – I had to add an entry point to load my own address tags for data that I wanted to save. Their idea of three only values, with address tags of 5555, 6666, and 7777 was not quite what suited my interest. Ensure that the target address is within the flash address space, and not occupied by your own code, and see what you get. What are you using for a development system? I am using Raisonance. I wrote a wrapper module to do the calls to EE_WriteVariable and EE_ReadVariable, so I would use the read on boot, and the write otherwise, and keep all the HAL type calls within an interface layer that can be replaced or re-written as porting may require. Note that ReadVariable needs a pointer, and WriteVariable does not. If I can help, let me know.
Dan
2017-09-08 02:56 AM
STM32L0 devices have up to 6 KB of EEPROM.