on my stm32g473 I need to save a variable permanently, even on reboot. I want to use it to control the volume of my dac, and use up and down buttons to change the gain. This variable has to be remembered ater reboot, should I write to flash?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-06 8:21 AM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-06 11:04 AM - edited ‎2023-11-20 8:48 AM
You can save all your parameters in flash permanently.
To minimize flash writes, load parameters from flash to RAM during startup and then also erase the data flash mmediatley (to prepare it for write).
Then you can work with RAM data parameters during runtime.
On shutdown save RAM parameters back to flash with write command.
To detect power shutdown use a GPIO or ADC input:
The large capacitor behind diode buffers the supply voltage for a short time. So there is enough time to write flash data on shutdown.
For more safety you can also use double flash buffering (e.g. for very short on/off switching)...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-06 9:24 AM - edited ‎2023-11-20 8:48 AM
you need a backup 3v3 cell, Vbat. then backup registers can keep content...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-06 10:26 AM
Reboot under power or with lost power ?
Read X-CUBE-EEPROM - EEPROM emulation expansion software for STM32Cube - STMicroelectronics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-06 11:04 AM - edited ‎2023-11-20 8:48 AM
You can save all your parameters in flash permanently.
To minimize flash writes, load parameters from flash to RAM during startup and then also erase the data flash mmediatley (to prepare it for write).
Then you can work with RAM data parameters during runtime.
On shutdown save RAM parameters back to flash with write command.
To detect power shutdown use a GPIO or ADC input:
The large capacitor behind diode buffers the supply voltage for a short time. So there is enough time to write flash data on shutdown.
For more safety you can also use double flash buffering (e.g. for very short on/off switching)...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-11 9:35 AM
Why not the eeprom?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-12 12:18 PM
i read about very limited write cycles allowed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-12 12:18 PM
thank you, that is very smart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-12 1:23 PM
Where did you read about the limited write cycles? There is no eeprom at all as i found out...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-12 2:51 PM - edited ‎2023-11-20 8:48 AM
see datasheet: 10.000 erase/write cycles are guaranteed for internal flash:
