Designing Non-Volatile Memory Storage
There are two main types of memory used in semiconductors: volatile memory and non-volatile memory. Volatile memory is called RAM, and its recorded content is lost when power is no longer supplied. Non-volatile memory is called ROM, and its recorded content is not lost even if the power supply stops. Within both RAM and ROM, there are further types based on differences in detailed structures and characteristics, which are used for different purposes. This article focuses on non-volatile memory and explains the characteristics of each type and points to note during design.
- Typical Non-Volatile Memory
- Memory Write Endurance
- Data Retention During Momentary Power Interruptions
- Recovery Design After Power Loss
Typical Non-Volatile Memory
There are three typical types of non-volatile memory.
EEPROM
This is a non-volatile memory that allows data to be electrically erased or rewritten by applying a voltage. Unlike PROM, which can only be written to once, it can be rewritten any number of times. It is characterized by the ability to erase and rewrite in 1-byte units, and is used to retain relatively small data such as saving setting values and recording counter values. Even for data that is frequently rewritten, it can withstand a considerable number of writes, making it sufficient for general applications. Although the write speed may be slower compared to other memories, this can be addressed by reducing the amount of information written at one time.
Flash Memory
Like EEPROM, it can be electrically erased and rewritten. Unlike EEPROM, it is characterized by processing in units of erase blocks, which are the minimum units for erasing and writing. It is suitable for writing large amounts of data quickly and efficiently. Although erasing in byte units is not possible, the structure can be simplified, allowing overall costs to be kept low. It is also commonly used as ROM to store programs executed by microcontrollers. In addition, because many of them are small, lightweight, and shock-resistant, they are used in portable USB flash drives, SD cards for digital cameras, and other devices.
Note that there are two types of flash memory: parallel flash memory, which transfers data in parallel, and serial flash memory, which transfers data sequentially one bit at a time. Parallel flash memory uses multiple signal lines to achieve high-speed transfer, but this increases the wiring accordingly. Serial flash memory has advantages in miniaturization and cost reduction because it transfers data using a small number of signal lines. Recently, high-speed serial flash memories such as QuadSPI have emerged, making serial flash memory the mainstream.
EEPROM Emulation
Using flash memory to emulate EEPROM is called EEPROM emulation. This is a mechanism that reserves a specific area within the flash memory for exclusive use, making it function as an EEPROM. Since EEPROM requires reading and writing for each byte, the word length of the EEPROM to be emulated is specified and reserved before using the dedicated area.
By using this EEPROM emulation function, the EEPROM itself becomes unnecessary, making it possible to reduce the number of components and simplify the design.
Memory Write Endurance
Memory reaches the end of its life through repeated erasing and writing. The upper limit of rewrite cycles varies depending on the product, but if a program rewrites data once per second, erasing and writing will occur every second. Even with a limit of 10,000 rewrite cycles, it would be reached in about 3 hours. Variables that are frequently updated, such as variables that serve as counters or timers, are usually placed in RAM rather than ROM.
If writing is concentrated in the same area, the memory will reach the end of its life sooner. Therefore, wear leveling is performed to prevent rewriting from concentrating on specific addresses. Wear leveling uses a controller that manages memory write locations and reallocates addresses so that erase counts are evenly distributed across blocks.
Data Retention During Momentary Power Interruptions
If a power loss occurs while data is being written or erased, it can cause data corruption and inconsistencies. To prevent failures during power loss, countermeasures are required in both hardware and software.
On the hardware side, a design is required that supplies even a small amount of power just before complete power loss, buying time for the memory to complete any unfinished operations or ongoing transfers.
On the software side, a journaling file system that periodically saves the file system is effective. By restoring from the journal, you can roll back to a slightly earlier normal state. If you reserve a bootloader area that is not rewritten during normal operations, you can also roll back to the previous state if the newly written program does not work.
Since either countermeasure is close to an emergency workaround, it is reassuring to also provide a backup battery system to prevent power loss in the first place.
Recovery Design After Power Loss
To prevent partially written data from remaining in the event of a power loss, it is also effective to include a mechanism to roll back transactions if they are incomplete. It is advisable to use this in combination with a mechanism that uses checksums or CRCs to verify data and ensure data integrity after recovery. Although it is not robust as an error detection mechanism, it is sufficient because it only detects data corruption, unlike cases of tampering or unauthorized access. Incorporate a mechanism that can also recover data after power is restored.


