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?

  • \$\begingroup\$ PIC32MX220F032B has 32kB Flash( not EEPROM!) and 3kB Boot Flash, the Atmega2560 has a 256kB flash and 4kB EEPROM. the EEPROM in the atmega is intended to be used as data storage, storing hard coded information such as strings, bitmaps etc, or for storing information that changes very rarely, like unique serial number etc. \$\endgroup\$
    – user7994
    Nov 19, 2015 at 20:37
  • \$\begingroup\$ The PIC32 is a pretty good processor series. The PIC32MX360F512L has 512K of flash, 32K EEPROM, and an 80MHz 32-bit CPU. If I had a choice between an ATMega and a PIC32 I would pick the PIC32. \$\endgroup\$
    – user4574
    Dec 14, 2016 at 20:29

2 Answers 2


"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.

  • \$\begingroup\$ You mentioned that for program code, use Flash mem because it does not change much. What about firmware updates? Those are program code, right? So if we are looking at it at the system level, entire code is erased and the new code is "Flashed". Is my understanding correct? \$\endgroup\$
    – phenomenon
    Nov 20, 2015 at 7:07
  • \$\begingroup\$ Yes. "Program space" is the FLASH memory on the PIC. Now it is possible to have the PIC code self-update the flash memory, which is how a bootloader works. But for the most part, this memory is programmed once (or a few times in the case of firmware updates) and that's it. So a 10,000 cycle-per-bit durability should last a typical PIC, well, forever unless it is writing to itself frequently. In prototyping, I may erase and re-flash a PIC hundreds of times; I have yet to have one fail prematurely. \$\endgroup\$
    – rdtsc
    Nov 20, 2015 at 14:57

EEPROM is typically for storing data like settings and logs. It can typically be erased/written in small sections. It typically can be written/erased more times than flash memory. Expensive in terms of chip area.

Flash is typically used for code execution. It typically must be erased/written in large blocks. The number of writes/erases is typically much less compared to EEPROM. It is typically cheaper to produce in terms of die area.

If you are woried about running out of code space it is instructive to compare the AT-Mega and the PIC32. If you are doing lots of 16 or 32 bit integer math, or floating point math you are probably better off with the PIC32. This is in terms of both flash memory useage and execution speed.

The ATMega part is going to use fewer bytes per instruction compared to the PIC32. A 32-bit CPU typically uses more bytes per instructionjust due to the larger operand sizes. On the other hand, an 8-bit CPU will often need many more instructions to do the same job as a 32-bit CPU.

For example a 32-bit x 32-bit multiply with a 32-bit result on a 32-bit CPU is two load instructions, a multiply instruction, and a store instruction. On an 8-bit CPU you would need at least 8 load instructions, 16 multiplies, several addition with cary instructions, and 4 store instructions. So the reduction in code size you get on an 8-bit CPU per op-code gets cancelled out by the increase in the number of op codes.

The PIC32 is a pretty good processor series. The PIC32MX360F512L has 512K of flash, 32K EEPROM, and an 80MHz 32-bit CPU. If I had a choice between an ATMega and a PIC32 I would pick the PIC32.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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