# Alternatives to using EEPROM

As I understand it, EEPROM is a part of a computer (in my case, an AVR microcontroller) which stores data, and holds on to it even when the device completely shuts down. It allows data to be written to it, and read from it.

The problem I am seeing is that it has a finite life, and a pretty short one. In other words, I can only read/write a finite number of times before I wear out the EEPROM.

What I am looking for is a way to achieve the same functionality as EEPROM, but in a small form factor. I suppose I can use something like a microSD card, but I would prefer a solution which does not require the user to buy a memory card. Additionally, I only really need a few bytes of space, at most. Let's just say 1 kB to be very, very conservative. I would be spending more than needed to accommodate a memory card of any sort.

So what are my options? Are there any common IC solutions which would allow me to achieve this kind of data storage/retrieval, without a short life and high cost?

-
How often do you need to save these few bytes? That's the key question here. Is it every minute? Hour? milisecond? – Gustavo Litovsky Feb 18 '13 at 19:09
The EEPROM of an ATmega32, for example, has a life of 100,000 write/read cycles. That could be more than enough, depending on the application.. – m.Alin Feb 18 '13 at 19:17
You said "I can only read/write a finite number of times before I wear out the EEPROM", which is not quite right. You wear out the EEPROM with writes, but generally reads are not limited. – The Photon Feb 18 '13 at 19:35
@GustavoLitovsky Let's say, once every minute. In which case, for an ATmega32 which is constantly on, it will last two years. I guess that is ok, when I put it in perspective. – capcom Feb 18 '13 at 19:57
@ThePhoton Ah, ok. I never knew that, thanks. Not that it changes anything, as I require both read/write. – capcom Feb 18 '13 at 19:58

Yes, an EEPROM is a type of nonvolatile memory which can hold data even without any power for a significant amount of time (the actual time depends on temperature and other conditions).

There are a few other non volatile solutions for you to consider:

1) Internal Flash memory - Most microcontrollers nowdays have Flash for code storage and some provide it for user data and logging as well. This also has limited write cycles and requires block erase before changing bits from '1' to '0' (you store data elsewhere in the meantime and then rewrite it).

2) Internal FRAM memory - TI has devices with FRAM memory which is nonvolatile, can be accessed very simply (like any other memory location. Reads are also destructive as writes (though in your case this might not matter since the number of cycles is 10^13 or so at 85 degrees celsius).

3) External Flash memory - You can add memory externally to hold a few megabits of data rather inexpensively.

Depending on the rate at which you want to save (and whether you can shutdown nicely) you might be able to increase the effective number of cycles available for you.

-

The way to overcome the endurance limitation of EEPROM is to apply a wear-leveling algorithm. Basically for every record you want to store you allocate N-times the memory requirement to it, and an corresponding space for N-index values, then use inference to figure out which is the "current record" and which is the next record to write to. It's well described in this AVR App Note.

-

Another potential solution is a bit of static ram, and a battery. This has a limited lifetime in that the battery will eventually die, but it's unlimited in write cycles. You could also use something like a large-ish capacitor to power it, if you know your off-time is going to be some smallish value. A lithium coin-cell can last a long time in an application like this, if you design it right.

There are also parts that incorporate an RTC, nvram and battery (to keep the clock running) in one part. These have the disadvantage that if the internal power source goes, you've lost the whole part (not just the battery), but depending on how long your product should last that might not be a problem.

-

I don't know what is your budget, but you might want to take a look at MRAM, which is fast as DRAM but non-volatile just like Flash. Of course, these are way more expensive than EEPROM chips.

I've got a bunch of sample ICs from Freescale years ago, but never had a chance to use them, so I can't really tell if you'll end up with a much simpler circuit than if you have to attach an SD card slot.

-

I'm a computer guy rather than an electrical engineer but I think there's another approach to the life cycle problem of flash memory:

My understanding is that the life cycle problem on flash is actually a matter of erasing, not writing. You can write as many times as you want except for the little detail that the writes are one-way only.

Since the storage you need is tiny compared to the size of even small devices you can (assuming you have sufficiently low level access to the hardware) write it out many times, each time in a different location. Make sure your data can be distinguished from unwritten memory (pad it if necessary to accomplish this) and the last written cell is the current value.

Furthermore, if your data is actually a counter being incremented once per write you can get even more out of it by not writing it at all, but rather writing out one bit per tick, the count is the number of bits written.

-

Serial NVSRAM from Microchip may fit your bill:

Serial NVSRAM offers non-volatile RAM storage and is ideal for applications that need to write very often to the memory. This device is significantly lower cost than other non-volatile RAM devices and the data is backed using an external battery. This 8-pin, SPI device supports unlimited instantaneous writes to the memory array, making it ideal in applications such as meters, data loggers, data recorders, black boxes. These devices are available in 512Kbits and 1Mbit densities.

This serial memory family supports battery backup. The datasheet mentions the current draw of 1ua from the battery. Price is less than \$2 in 1K qty and free samples are offered by Microchip. ICs are available in hobbyist friendly PDIP and SOIC packages.

-

You may want to look into serial FRAM. The main manufacturer seems to be Cypress (née Ramtron). Here's one part:

http://www.cypress.com/?rID=73530

It's available in large sizes (the biggest I've seen is 2Mbit), it's protocol compatible with MRAM or flash, it's byte read-writeable without needing erasing, it's fast --- writes keep up with the SPI protocol --- and the retention is ludicrously high.

That said, it's a bit hard to find. Not many distributors carry it and those that do seem to sell out instantly --- Cypress have their own store (free shipping, too) and between me ordering two FM25V04 parts they sold out. Six weeks lead time, apparently...

-