Why is there both Flash and EEPROM in a microcontroller
The data of the microcontroller running in RAM (random memory), the data in RAM can not be retained after power down, so how to make the data not lost after power down? This requires the use of memory such as EEPROM or flashROM for this purpose.
Insert a paragraph: the ROM was initially not programmable, whatever content was shipped was forever, inflexible. Then came PROM, which could write itself once, and if it was wrong, you could only change the piece. With the continuous improvement, finally appeared the EPROM can be erased and written several times, each erase to take the chip to the ultraviolet light, think you put a program on the microcontroller found a place need to add a sentence, for this you have to put the microcontroller under the ultraviolet light for half an hour, and then can be next, so toss a day can not change a few times. The wheels of history kept moving forward and the great EEPROM came to the rescue, saving a large number of programmers from finally being able to modify the contents of the ROM at will.
The full name of EEPROM is "Electrically Erasable Programmable Read-Only Memory". It is relative to the rom of UV erasure. But today there exist multiple variants of EEPROMs that have become a generic term for a class of memory.
EEPROM in the narrow sense.
The feature of this rom is that it can access and modify any byte at random, and can write a 0 or a 1 to each bit. This is the most traditional kind of EEPROM, no data loss after power down, can be kept for 100 years and can be erased and written 100w times. Has high reliability, but the circuitry is complex/costly as well. Therefore, current EEPROMs are in the tens to hundreds of kilobytes range, and rarely exceed 512K.
Flash belongs to the broad category of EEPROM, as it is also an electrically erased ROM. But to distinguish it from the usual byte-by-byte erasure EEPROM, we call it Flash.
Why do you need both Flash and EEPROM in a microcontroller if they are similar?
Usually, the Flash in the microcontroller are used to store the running code, in the running process can not be changed; EEPROM is used to save user data, the running process can be changed, for example, a clock alarm time is initially set to 12:00, and later changed to 6:00 in the running, which is saved in the EEPROM, not afraid of power failure, even if the power is reapplied, there is no need to readjust to 6:00.
But the biggest difference is actually: FLASH operates by sectors, EEPROM operates by bytes, the two addressing methods are different, the structure of the memory cell is also different, FLASH's circuit structure is simpler, the same capacity accounts for a smaller chip area, the cost is naturally lower than EEPROM, thus suitable for use as program memory, EEPROM is more used as non-volatile data memory. Of course, FLASH can be used as data memory, but the operation is much more troublesome than EEPROM, so the more "user-friendly" MCU design will integrate FLASH and EEPROM two kinds of non-volatile memory, while the cheap design is often only FLASH, early can be electrically erased type MCU are EEPRM structure, now has been largely discontinued.
In the internal circuitry of the chip, FLASH and EEPROM not only have different circuitry, but also different address spaces, and naturally different operation methods and instructions, both for the von Neumann and Harvard architectures. Technically, both program memory and non-volatile data memory can use only the FALSH structure or the EEPROM structure, or even use "workaround" technology to simulate a "data storage area" in the program memory area, but even so, they are still conceptually different, which is a matter of basic common sense.
EEPROM: Electrically erasable programmable read-only memory, the operating characteristics of Flash are fully consistent with the definition of EEPROM, and is undoubtedly an EEPROM, which was clearly marked as such in the datasheet when the first Flash was introduced, and is also marked as such in most Flash manuals today. The main reason why the industry wants to distinguish between the two is that Flash EEPROMs operate very differently from traditional EEPROMs, and the secondary reason is that for the sake of language brevity, Flash EEPROMs are simply referred to as Flash in informal and colloquial documents.
Flash is characterized by its simple structure, the same process and the same wafer area can get higher capacity and faster operation under large data volume, but the disadvantage is that the operation process is troublesome, especially in the small amount of data repeatedly rewritten, so the Flash structure in the MCU is suitable for program memory that does not need frequent rewriting.
Many applications require frequent rewriting of certain small amounts of data and need to be power-down non-volatile, so the traditional structure of EEPROM is well suited here, so many MCUs are designed with two internal EEPROM structures, FLASH and traditional, in order to obtain a balance of cost and functionality, which is very convenient for users. With the popularity of ISP and IAP, especially in MCU families where the program memory address space and data memory address space overlap, more and more MCU manufacturers are now using IAP-enabled program memory to emulate the EEPROM counterpart of data memory, which is a workaround method for implementing non-volatile data memory at low cost. In order to obtain the "equivalence" with the dual EEPROM process in commercial promotion, many manufacturers who use Flash program memory to "emulate" (note that the technical concept is not a real emulation) the eeprom data memory have claimed that their products are with EEPROM, strictly speaking, this is very loose, but businessmen have businessmen's purpose and methods, using Flash to "emulate" EEPROM can gain greater commercial benefits, so in fact, the technical concept of confusion is caused by them.
In terms of cost, it is cost effective to use Flash to "emulate" EEPROM, and the other way around, no one will do it. This may be out of some MCUs where program storage and data storage are contiguous. The low-end MCUs in this category, especially those with small storage capacity, still use EEPROM as non-volatile memory, which is rather cheaper in cost than designs with dual process of Flash and conventional EEPROM, but this phenomenon is only limited to the small capacity premise. Due to the popularity of the Flash process, many businessmen and less than rigorous technicians now refer to program memory as Flash, and for those MCUs that only use the traditional EEPROM process, they do not seek to understand much, so they incorrectly refer to EEPROM program memory as "analog Flash", the fundamental reason is that they do not understand that Flash is only a memory structure and not a memory purpose, the wrong premise naturally leads to the wrong conclusion. Commercially speaking, emulating Flash with EEPROM is a foolish act that no one would really do, it goes against the commercial pursuit of maximum profit, and it's not technically feasible for the technician. The essential problem is that Flash is a type of memory and not program memory in the MCU, and even though the MCU uses Flash for its program memory, its inverse proposition does not hold.
A family opinion, what do you think?