Saturday, 10 December 2016

flash - Why do most of the non-volatile memories have logical 1 as the default state?


I have used non volatile memory, like EEPROM and FLASH memory, in embedded applications and I have always found that unused memory (EEPROM/FLASH) bit locations are always set to 1 by default. Why is this used instead of 0?


For example an address, say 0th address (first byte of memory), if not written to by the user, always stores 0xff and not 0x00. Why is it that people who built the memory chips kept it that way? I'm sure keeping the default memory location as 0xff would provide some advantage or something important for the manufacturer.


What is the reason behind this structure in memory chips?




Answer



I am going to discuss flash memory programming, but a lot of material will be similar to EEPROMs (Electrically Erasable Programmable ROM), since flash memory was derived from EEPROMs in the mid 1980's. As described below, from a physical standpoint, the default state is 1's. But more importantly, I'm going to explain why there is a default state -- you can't just arbitrarily program on top of what is already programmed from last time.


NOR flash is almost always chosen for program flash since the interface is best suited for placing the data within the memory map of the microcontroller -- full address and data busses mimic RAM and allow random access to any location. Data can be read one word at a time, where a word is defined as the data width of the microcontroller, typically 8, 16, or 32-bits. NAND flash, on the other hand was developed to replace hard drives and works sequentially.


However programming gets a little more complicated. As already mentioned, the default state for NOR flash and other non-volatile memories like NAND flash, EEPROMs and even EPROMs is a logic 1. You cannot program 1's into these devices, you can only program 0's. So for example if you have a byte containing 0x0123 and you want to change it to 0x3210, you can't do so directly like writing over a byte in RAM.


Instead, bits in the memory must be erased, which puts them into the default 1 state already mentioned. This can only be done in blocks, not words. On the Microchip PIC32, which I have worked with the most lately, the minimum block size that can be erased is 4096 bytes. So if you wanted to change just one word (32-bits), you would have to read the 4K of memory, erase the block, then write the 4K of memory back to flash but including the new 32-bit value as needed. This erasing can take some time -- a good part of a second.


The following is a picture of a flash memory cell. Flash stores the data by removing or putting electrons on the floating gate. When electrons are present on the floating gate, no current flows through the transistor, indicating a 0. When electrons are removed from the floating gate, the transistor starts conducting, indicating a 1. (This is by convention -- it could have been the other way but would required inverters on all the data lines.)


enter image description here


Erase operation. The default state of flash memory cells (a single-level NOR flash cell) is 1 because floating gates carry no negative charges. Erasing a flash-memory cell (resetting to a 1) is achieved by applying a voltage across the source and control gate (word line). The voltage can be in the range of -9V to -12V. And also apply around 6V to the source. The electrons in the floating gate are pulled off and transferred to the source by quantum tunneling. In other words, electrons tunnel from the floating gate to the source and substrate.


Because erasing uses high voltages, so erasing in blocks requires less die area. So voltages can only be applied to entire rows of transistors at a time.


For writing, a NOR flash cell can be programmed, or set to a 0 by the following procedure. While writing, a high voltage of around 12V is applied to the control gate (word line). If a high voltage around 7V is applied to bit Line (drain terminal), a 0 is stored in the cell. The channel is now turned on, so electrons can flow from the source to the drain. The source-drain current is sufficiently high to cause some high-energy electrons to jump through the insulating layer onto the floating gate via a process called hot-electron injection.



For reading, a voltage of around 5V is applied to the control gate and around 1V to the drain. The state of the memory cell is distinguished by the current flowing between the drain and the source.


The useable life of non-volatile memory is measured in terms of erase cycles. The disadvantage of NOR is that the number of erase cycles is about 1/10 that of NAND memory. Many versions of the PIC32 only allow the flash memory to be updated 1000 times, way less then the typical 100,000 erase cycles for EEPROMs.


So it is not so important if the designers made the default state is 1 or 0 (they chose the value that permitted the easiest implementation); the important thing is that one has to erase a block of flash first (which takes time), and then reprogram the entire block (even if a single word is being changed (which requires a substantial amount of RAM).


This block erasing of the device goes back to the first EPROMs (Erasable Programmable ROM), which proceeded EEPROMs The code was programmed into chips (like the 16KB 27128) and placed in sockets. These chips had a little window on top which allowed light to shine on the die. When the program had to be changed, the chips were put into a UV eraser for 20 minutes or so, which would erase the entire chip. Then the chip would be programmed with the new program.


Some EEPROMs require erasing of blocks of memory before programming; others allow writing a byte at a time (the EEPROM controller actually erases the byte first and the programs it).


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...