Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
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. – user7994 Nov 19 '15 at 20:37
    
That was spot on. Thanks. – phenomenon Nov 20 '15 at 7:04

"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, 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, but each bit still takes up quite a bit of space.

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

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 10x the durability of FLASH.

share|improve this answer
    
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? – phenomenon Nov 20 '15 at 7:07
    
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. – rdtsc Nov 20 '15 at 14:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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