5
\$\begingroup\$

Before I get to the question, let me give you some background info.

I'm trying to make a digitally controlled power supply. I'm going to use an MCP4725 DAC to set the reference voltage for the power supply. The DAC will be controlled by an STM32 Blue Pill development board.

When I turn the PSU off, I want to store the last set output voltage in the DAC's EEPROM so that when I turn the PSU on again, it will output the same voltage as it was before I turned it off.

When I was going through this article about the DAC, I came across this statement:

You shouldn't set the flag to true unless you require it as it will take longer to do, and you could wear out the EEPROM if you write it over 20,000 times.

I went through the datasheet of the DAC twice and I did not find the above statement anywhere (Sections 5.6 and 8.2 of the datasheet talk about the DAC's EEPROM).

My questions are:

  • Why does Adafruit say that the DAC's EEPROM will wear out after 20,000 write operations when there is no mention of such a thing in the DAC's datasheet?
  • What do they mean by "wear out"? Will the EEPROM circuit get damaged or can it not store more than 20,000 voltage values?
  • How do I erase the EEPROM so that it doesn't wear out (if running out of memory is what "wears it out")?
\$\endgroup\$
8
  • 2
    \$\begingroup\$ use the non-save call to set the voltage, then wait a few seconds and set it again with save, to the same value for persistence and wear-avoidance. This avoids writing 50 values as you dial up and decide on an output. \$\endgroup\$
    – dandavis
    Aug 10, 2021 at 5:01
  • 1
    \$\begingroup\$ @JRE you made this correction: What do they mean by "wear out"ou?". According to this website, when the stuff in the quotation marks isn't a stand-alone sentence, the full stop (can extrapolate to question mark too, I suppose), should be outside the quotation marks. \$\endgroup\$ Aug 10, 2021 at 11:18
  • \$\begingroup\$ @PrathikPrashanth: Difference between US English and UK English. I wouldn't just change from UK to US - both are valid. If I have to fix other things, though, I change everything to the standard I was taught in school. \$\endgroup\$
    – JRE
    Aug 10, 2021 at 11:22
  • \$\begingroup\$ @PrathikPrashanth I agree with you. The stuff inside the quotation marks in not a quoted question, so it doesn't read properly to put the question mark inside those quotes. It would be different if the quotation marks surrounded a complete sentence that was a question. \$\endgroup\$ Aug 10, 2021 at 12:09
  • \$\begingroup\$ @ElliotAlderson even the question mark inside the brackets should be moved back out, if I'm not wrong - How do I erase the EEPROM so that it doesn't wear out (if running out of memory is what "wears it out"?) \$\endgroup\$ Aug 10, 2021 at 12:27

2 Answers 2

9
\$\begingroup\$

All EEPROMS have a finite write cycle endurance (all FLASH memory too). There are more exotic forms of non-volatile memory (MRAM, FRAM, or simply battery-backed RAM) that have infinite write endurance but most "normal" non-volatile memory will wear out over a certain number of write cycles. This spec is commonly 100,000 cycles or 1 million cycles for regular EEPROM parts. As @jpa pointed out, this datasheet does specify a write endurance of 1 million cycles, so it's pretty standard.

It's always important to note that the write endurance specification presumes "normal" writes with adequate time from one write to the next. If you perform a large number of writes rapidly (for example, when developing code it's common to have a bug where the code accidentally enters a small write-loop), then the part will fail much sooner than its spec. (This, along with operating at temperatures different from the nominal 25°C, might by why Adafruit published the much more conservative estimate of 20k cycles, but I'm just guessing here.)

So, regarding your questions:

  1. As @jpa pointed out, there is in fact a mention, so no issue here.
  2. When the part "wears out" it will no longer reliably hold the value you wrote to it. If you're lucky (and or the part is thoroughly worn out), you'll end up with "stuck bits" that always sit at a 1 value or a 0 value. If you're unlucky or the part is just starting to fail, you'll have a value that looks correct when you write it, but later on the voltage (and bit reading) have drifted back to the wrong value. No fun.
  3. The EEPROM gets worn out by writing values to it, so there's no way to avoid this problem except avoiding writing to the EEPROM.

Just figure out a scheme that writes to EEPROM as infrequently as possible, while still meeting your non-volatile storage needs. And then do a bit of math to estimate your expected EEPROM lifetime.

\$\endgroup\$
3
  • 4
    \$\begingroup\$ Regarding 1.: the datasheet does mention EEPROM endurance (as 1 million write cycles), even though OP didn't notice it. I have no idea where Adafruit's 20 000 comes from. No vendor mistake as far as I can tell. \$\endgroup\$
    – jpa
    Aug 10, 2021 at 13:59
  • 1
    \$\begingroup\$ @jpa I found it now. It was in the electrical characteristics table under the name "endurance". I thought I would find it in a paragraph. \$\endgroup\$ Aug 10, 2021 at 15:03
  • 1
    \$\begingroup\$ @jpa well noted (as you've probably guessed I just took OP's word for it and didn't review the datasheet myself). I've corrected to reflect this. \$\endgroup\$
    – Mr. Snrub
    Aug 11, 2021 at 1:42
7
\$\begingroup\$

We don't know why Adafruit says that. You should ask them about it.

The datasheet says the EEPROM endurance at room temperature is 1 million write cycles.

The EEPROM does wear out. It gets a small amount of damage each time it is written, as internally it erases the cells and reprograms them. It's not about getting full, and you can't erase it or do anything about it.

After enough erase/write cycles, it is damaged enough to not hold the written value for the specified time. So if it typically can hold the value for 200 years, after 1 million writes the time can be lower, but there is no guarantee how many years it is. Given enough writes, it might not hold the written value at all.

The only thing you can do is to not write it. If you store to the EEPROM, it can take up to 50 milliseconds, meaning the update rate can be as low as 20 writes per second.

It might be better to store the value somewhere else or maybe only at power off.

\$\endgroup\$
11
  • \$\begingroup\$ Yea, I only want to store a value during power off. Is it possible to store the set value in the STM32 itself and restore it later? \$\endgroup\$ Aug 10, 2021 at 5:55
  • 4
    \$\begingroup\$ @MituRaj the mechanism is different in EEPROM and Flash types. Erase and program cycles apply large voltage fields to tunnel electrons in or out a floating gate, and after many cycles less and less electrons will move and voltage differential becomes too small to determine if it is a logic 1 or 0. The oxide that insulates the floating gate can also deteriorate and start leaking electrons so the floating gate does not hold the charge that was transferred to it. \$\endgroup\$
    – Justme
    Aug 10, 2021 at 7:08
  • 2
    \$\begingroup\$ @PrathikPrashanth No that is not true either - it is not 10k write operations, it's 10k erase operations. Obviously you would use a smart wear leveling algorithm that fills a whole page before erasing. You could also use the battery backup SRAM for storing voltages, as it's just SRAM. \$\endgroup\$
    – Justme
    Aug 10, 2021 at 7:17
  • 2
    \$\begingroup\$ @SimSon That is not true and I already explained how it is done. Of course erasing a block just because you want to write one byte would be a bad way to do it. \$\endgroup\$
    – Justme
    Aug 10, 2021 at 9:02
  • 1
    \$\begingroup\$ It looks like storing the set voltage value in the DAC during power down is probable the best idea since the DAC can endure 20,000 - 1,000,000 write operations. \$\endgroup\$ Aug 10, 2021 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.