0

I'm implementing eeprom emulation with the STM32G0 series microprocessor. I am using the AN4894 Application note and the X-CUBE-EEPROM(4.0.0) software, but I have encountered a problem.

AN4894 Application note

X-CUBE-EEPROM

Let me explain how I use it first. I'm recording 128 values that are 32 bits, and this value is constantly updated. For example, every time I press the button, the value increases and records this value.

As the application note says, a minimum of 2 pages can be used.

enter image description here

When I use GUARD_PAGES_NUMBER as 0, it uses 2 pages for the eeprom emulation, but the values that have been written are constantly updated, the 2-page field fills up and the change process does not occur again.

enter image description here

The value of GUARD_PAGES_NUMBER is 0, 2, 4 ... it can get its values. when I use the value 2. When updating the values, when the first 2 pages are full, the last values are copied to the other 2 pages and the values are not lost.

enter image description here

The protection of values is exactly what I want. But when I use it like this, at LEAST 4 PAGES are used. Each page is 2kb for the STM32G0 series, a total of 8kb is allocated for this process. Taking up 8kb of space for 128 values of 32 bits each is undesirable for my application.

In a scenario where the saved values can be changed periodically, but there is no data loss or flash field filling problem, I can use a minimum of how many pages. It is convenient for me to use no more than 2 pages.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
mefilti
  • 1
  • 1
  • 1
    Writing values to EEPROM every time it changes is really not a good idea. You can choose to write the changed values before the uC is powered down by detecting a power loss/down using some mechanism. Or write the changed value at some periodic intervals e.g. every 5 minutes or every 15 minutes, but this is also not a good idea. – Gaurav Pathak Jan 10 '22 at 09:15
  • 1
    Also, it seems that you do not want to lose previously written data. In that case you can allocate a buffer / array of 2kb. Before writing the new data, read the EEPROM in the 2kb buffer, check how many bytes of useful data the buffer has (check for subsequent 0xFF, or 0x00 depending on how EEPROM is being erased), append the new data after the end of the previous data and then write the buffer with old+new data to EEPROM. But again this will impact the performance if this is done frequently cause EEPROM read and write takes time. – Gaurav Pathak Jan 10 '22 at 09:22
  • You may also want to track how many complete pages you have consumed so that if you happen to write on to a new page then it is not useful to read the data of a previous page. – Gaurav Pathak Jan 10 '22 at 09:25
  • As you said, it will take a lot of time to do this in each transaction. I'll evaluate what you've said. Thanks – mefilti Jan 10 '22 at 09:43
  • What did the folks at st say about this when you contacted their support? – old_timer Jan 10 '22 at 14:59
  • Have not received a reply yet. – mefilti Jan 10 '22 at 15:06

0 Answers0