cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with X-CUBE-EEPROM

derLalla
Associate

Hey everyone,

 

I have a problem in understanding the X-CUBE-EEPROM when using it with the STM32G0B1xx. 

1. What is meant by kcycles? Does it mean 1000 cycles? The documentation (https://www.st.com/resource/en/application_note/an4894-how-to-use-eeprom-emulation-on-stm32-mcus-stmicroelectronics.pdf) says i have 10kycles per page. One page saves up to 252 elements. Does it mean I can write a 32bit (4 byte) variable 252 * 10000 times? What happens after that?

2. I am thinking of implementing my own smaller version of the emulated eeprom. I have 2 variables (8 bytes) which I continuously need to write to the flash. So I could write each variable at a fix memory address, lets say 0x08080000 and 0x08080004. Of course I would loose all the benefits of having data retention, etc. but how often could I write a new value to these addresses? 
Over the lifetime of my use case (a battery) the variable could be written 300.000 times, at always the same address, is this feasible?

 

So with the need for 300.000 writes, did I understand number 1.) correctly and would 2.) also be feasible?

 

Regards,

René

 

1 ACCEPTED SOLUTION

Accepted Solutions


Yes: k = 1000, so kcycles = 1000 cycles.

A "cycle" means an erase cylce - it's the erasing that causes wear in EEPROM.

You have to erase a whole page at once - so it doesn't matter how many bytes within that page are used.

 


@derLalla wrote:

2. I am thinking of implementing my own smaller version of the emulated eeprom. I have 2 variables (8 bytes) which I continuously need to write to the flash. So I could write each variable at a fix memory address, lets say 0x08080000 and 0x08080004. Of course I would loose all the benefits of having data retention, etc. but how often could I write a new value to these addresses? 


To re-write the same address, you would need to erase the whole page.

So a better approach would be  to write to a different address each time - then you only have to erase the page when you've gone through all its addresses.

Of course, this needs some overhead to record which is the "current" address in use.

Other ways to reduce wear on the storage:

  • Only write when the data has actually changed.
  • Keep a "working" value in RAM, and only update the flash (relatively) infrequently. Have power-fail detection, and enough backup power to allow you to save the current RAM value to flash before you die.

 

View solution in original post

3 REPLIES 3


Yes: k = 1000, so kcycles = 1000 cycles.

A "cycle" means an erase cylce - it's the erasing that causes wear in EEPROM.

You have to erase a whole page at once - so it doesn't matter how many bytes within that page are used.

 


@derLalla wrote:

2. I am thinking of implementing my own smaller version of the emulated eeprom. I have 2 variables (8 bytes) which I continuously need to write to the flash. So I could write each variable at a fix memory address, lets say 0x08080000 and 0x08080004. Of course I would loose all the benefits of having data retention, etc. but how often could I write a new value to these addresses? 


To re-write the same address, you would need to erase the whole page.

So a better approach would be  to write to a different address each time - then you only have to erase the page when you've gone through all its addresses.

Of course, this needs some overhead to record which is the "current" address in use.

Other ways to reduce wear on the storage:

  • Only write when the data has actually changed.
  • Keep a "working" value in RAM, and only update the flash (relatively) infrequently. Have power-fail detection, and enough backup power to allow you to save the current RAM value to flash before you die.

 

derLalla
Associate

Thank you very much for your fast response! 
So, I always need to erase a page, before writing to the same address again. But what would happen, if I just write to the same address, without erasing the page? 
My page size is 2kB which is quite large for my application. It would be nice to just use 100bytes in total.


@derLalla wrote:

So, I always need to erase a page, before writing to the same address again. But what would happen, if I just write to the same address, without erasing the page? 


EEPROM writing consists of "clearing" (to zero) erased bits - so, as long as your write is only to clear bits, you can write multiple times to the same location.

But bits can only be set to one by erasing.

 


@derLalla wrote:

My page size is 2kB which is quite large for my application. It would be nice to just use 100bytes in total.


You can fit 100 bytes into a 2k page (2000 bytes) twenty times; if it's actually 2K (2048) you have 48 bytes spare.

So, again, you can organise your 2K page into 100 "slots"; each time you write, you use a new "slot" - so you get 100 writes before you need to erase the page.

You can use the spare 48 bytes to manage identifying which is the current "slot"