Primary diff between EEPROM and Flash mem, in terms of code memory

atmegaeepromflashmicrocontrollerpic

In terms of storing program commands, what is the definable difference between EEPROM and Flash memory?

Also, in this particular context –
For a personal project developing audio codec using TI AIC3254, a developer zeroed in on Microchips PIC32MX220F032B. Its a 32bit MCU with 32kB EEPROM. It also has 3kB aux Flash with 8kB RAM.

Due to complexity, we are now deciding to use Arduino Mega 2560 based on ATMega 2560, which is 8-bit but 256kB Flash, 4Kb EEPROM and 8kB RAM.

What is the difference here? Flash and EEPROM what diff does it make when storing code?

Best Answer

"EEPROM" is typically used to store relatively smaller amounts of code. This is due to the evolution of ROM technologies:

  • PROM (Programmable Read-Only Memory) or OTP (one-time programmable) is the oldest type of ROM. These were commonly used in video console cartridges where programmable (and non-modifiable) code was desired. Storage was quite limited, usually measured in bits, and they appeared as "regular integrated circuits." Their retention is very long, but each bit takes up a large area, so producing an IC with large storage capabilities is challenging.

  • EPROM (Erasable PROM) was the successor to PROM in many ways, however often only differed by the silicon die being visible through a quartz window on top of the chip. Exposing the die to ultraviolet light reset all of the stored bits and it could be programmed again, a limited number of times. These were once used for computer BIOSes, since "upgrading it" meant the ROM just had to be erased and reprogrammed. Their retention is good[1], however are susceptible to accidental erasure.

  • EEPROM (electrically-erasable PROM) was the successor to EPROM by allowing the erasure to be done electrically, no longer requiring UV lamps and removing/reinstalling the IC. These too, worked more with bits than bytes or larger units of storage and were quite limited. Retention is quite good[2], but each bit still takes up quite a bit of space physically, making large volumes of storage impractical.

  • FLASH ROM, is the successor to all of these. They are a ROM in the sense that writing data is "permanent" (reality: 10 to 50 years retention[3] or so) but are erasable and reprogrammable. The biggest difference between FLASH and EEPROM is that FLASH is optimized to work on bytes or (blocks/pages) data, so are much faster than EEPROM. This lends them to mass-storage roles more readily than an EEPROM would, and that is why they proliferate the removable media market currently. They also found a way to cram more bits into a given area, increasing the storage density. However as a trade-off, the durability of each bit is lessened.

Now a PIC microcontroller typically has FLASH code memory, and optionally a little bit of EEPROM for general-purpose storage.

The main difference between these on the PIC, and what you want to know is: The FLASH write/erase endurance is about 10,000 times per bit. After that, this bit will be "dead" and no longer usable. The EEPROM write/erase durability is typically 100,000 cycles per bit. The retention seems to decline with the number of write/erase cycles, but finding data on this is very difficult.

[1] "[EPROM] retention in excess of 5 years at 225°C." http://www.northropgrumman.com/Capabilities/RadiationHardenedEEPROMS/Documents/256k_eeprom_paper.pdf pg 1.

[2] "[Devices] under testing have demonstrated greater than 10 years at 70ºC upon projection. But, Agency 1 also claims that there is a likelihood of having a sub-population of early failures within the total population, likely to represent no more than 1-in-15 to 1-in-30 devices. Intermittent data retention behavior was observed during the testing, but the cause of this behavior is not understood." https://nepp.nasa.gov/files/16152/05_001%20Chen%20%20EEPROM%20Final%20Report.pdf pg 3-4.

[3] "[Flash] nonvolatility implies at least ten years of charge retention." http://www.engr.sjsu.edu/wdu/ME296N/2006/Lecture/FlashMemory2.pdf pg 7-8.

So the bottom line is, use FLASH for your program code, since that usually doesn't change much (if at all) and there is plenty of space for the program (since it is the FLASH type.) Use the EEPROM area for non-volatile data storage, as it has both better retention, and roughly 10x the durability of FLASH.