How to reset Emulated EEPROM (in MCU Flash) when new code is uploaded?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 12:33 AM - last edited on ‎2025-02-25 6:23 AM by Andrew Neil
Title edited to make clear that this is emulated EEPROM - in the MCU's Flash.
How to reset the EEPROM every time a new code is uploaded?
Is this possible?
Thank you very much.
- Labels:
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 12:40 AM - edited ‎2025-02-25 12:42 AM
Hello Joker,
Just as an example:
You have to find the datasheet for your EEPROM chip and find the Erase Operation command, so in your microcontroller you can send it.
For example, you check in your eeprom for a value that must be FF, if it is not FF, you clean the EEPROM.
Hope it helps.
Greetings
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 12:51 AM
Hi, thanks for the answer, will the operation be performed only when uploading new code, or every time the MCU is booted?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 12:53 AM
@JokerJok wrote:the EEPROM
What EEPROM ?
Please see How to write your question to maximize your chances to find a solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 12:54 AM
It's up to you and how you make the code work.
My words refer to the hypothetical case where you write your own code to check the EEPROM every time the MCU boots.
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 12:55 AM
You have to write the code to do it - so it will happen whenever you code it to happen!
You need to give more details about your system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 5:09 AM
my MCU is: stm32f030rct
These are the addresses I want to reset their contents every time I upload new code.
I have some BYTEs that I store in EEPROM, and I reload them every time I boot the system.
But while I'm uploading new code, I would be happy if it were possible to reset the EEPROM every time I write code.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 5:25 AM
Perhaps use __TIME__ preprocessor define, and mark as a tag in EEPROM. Check if is consistent, erase and re-tag when it's different.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 6:21 AM
Again, please see How to write your question to maximize your chances to find a solution. It tells you how to properly insert source code - not as screenshots.
See also: How to insert source code.
@JokerJok wrote:These are the addresses I want to reset their contents every time I upload new code.
Right: so you're not actually using an EEPROM at all - you're emulating EEPROM in the microcontroller's Flash memory!
If you want to erase this emulated EEPROM when reprogramming, just do a complete chip erase before programming. Or, at least, ensure that the part of the Flash used by the emulated EEPROM gets erased during programming.
