Persistant memory storage after power loss

Hi All,

I'm sure this is a newbie/RTFM questions, but here it goes!

I have a Mega and Due board. Where/how do I store data which is available after power is removed and reapplied?

I'm working on a counter project and need to store an long (or converted to bytes) so that when the power is turned back on, the value can be read and the counter can be increased while the board has power.

As part of that question, what are any potential issues with updating the stored value every second?

Thanks,
Michael

Found this with some Googling: GitHub - PhiJu5/DueFlashStorage: Due EEPROM emulation

Looks like it does what I want.

The question is, based on this comment on the attached blog post, updating the flash every second is NOT a good idea, correct?

"Meanwhile, I tried to find definitive info on flash lifetime for the ATSAM8XE controllers with no luck. Lots of info on AVR based controllers, most of which agree to 10,000 writes for flash, 100,000 writes for EEPROM."

Thank you,
Michael

DueFlashStorage will work but you do need to keep in mind a couple of things

  1. Yes, there are limited writes to FLASH. I think you can program it about 10,000 times. So, every second would be a bad idea for sure. EEPROM is longer lived, an external EEPROM module should be able to handle 1 million writes.

  2. In order to upload a new sketch you must erase the entire FLASH memory first. You'll lose all of your stored data.

Your best bet is to add an I2C connected EEPROM chip if you can. They last longer and they don't lose their settings when you upload firmware. Even so, 1 million seconds is 11.57 days so if you're writing every second and you leave the thing on you'll ruin the EEPROM within two weeks. As such, it is better to either only write when something changes or try to write much less frequently. If the board could lose power and you want to save changes you can rig up a circuit that detects that the power is gone and tells the processor to quickly drop everything and write to EEPROM. This allows you to only write when the power dies rather than all of the time. Otherwise the settings and values can all persist in RAM.

Thanks for the quick response AdderD.

I found these FRAM, or Ferroelectric Ram breakout boards:

According to the description, FRAM has read/write of 10,000,000,000,000 times. That solves my problem, I think.

Have you used a FRAM board?

mlucas:
Have you used a FRAM board?

No, but I normally add a footprint to most of my PCBs for a low cost 8pin SOIC I2C 2kbyte FRAM.

The Cypress version of that FRAM claims a read\write endurance of 100 Trillion times.

Very handy.

Thanks. The FRAMs arrived today. I will get them a shot later this week.

Michael