Section 2.6 Memory
Memory is used to store binary data. Registers (introduced in SectionΒ 2.4) represent a particular type of memory. Memory can refer to volatile memory or non-volatile memory, depending on whether or not the contents of memory persist after power is removed from the microcontroller. The contents of volatile memory will be erased if power is removed, whereas non-volatile memory will be retained even after power is removed.
Modern computers (including desktops, laptops, tablets, and smart phones) have a nearly unlimited supply of memory of all types compared to microcontrollers. Microcontrollers typically have much more limited memory capacity. This means that it is necessary to be aware of size constraints while writing applications for microcontrollers.
Subsection 2.6.1 Volatile Memory
Volatile memory is used for temporary storage because data is unable to persist after power has been removed from the device. Random-access memory (RAM) is, for the most part, volatile memory. Random-access refers to the ability to obtain data from any arbitrary (or random) address in memory at any given time. RAM on a microcontroller is typically used to store information or data that is generated or accessed as a program is executed.
Aside
Types of RAM include static RAM (SRAM), dynamic RAM (DRAM), and registers. Static RAM (SRAM) is characterized by
-
use of flip-flops,
-
faster operating speed than DRAM,
-
higher cost than DRAM, and
-
low power consumption.
DRAM is the type of volatile memory used in computers due to its small size and low cost. DRAM is characterized by
-
use of only one transistor and one capacitor,
-
slower operating speed than SRAM,
-
lower cost than SRAM,
-
smaller footprint than SRAM,
-
high power consumption, and
-
requirement of constant refreshing (as otherwise the capacitors will slowly discharge over time).
Subsection 2.6.2 Non-Volatile Memory
Non-volatile memory is used for more permanent storage because the data persists after power has been removed from the device. Over the years, non-volatile memory has taken on many different diverse forms: paper punch cards; wax cylinders and vinyl records; optical CD and DVD disks; magnetic disks, drives and tape; and semiconductor drives.
Read-only memory (ROM) refers to a type of non-volatile memory. The name ROM is slightly misleading in modern times due to the easy ability to write to it. Historically, ROM was not a type of memory that could be written to after being initially programmed. In modern times, writing to ROM typically requires a higher voltage or a strict timing requirement on the write pins than a read operation requires. This is to prevent data from being accidentally overwritten during otherwise normal operation.
Because non-volatile memory doesnβt require power to hold on to stored data, it is used to store firmware on computers and program instructions and constants on microcontrollers. Program memory contains the instructions used to tell the microcontroller (or microprocessor or computer) how to boot up, run programs, and access data. In a computer, the instructions that tell the computer how to boot up is typically known as firmware or a BIOS (basic I/O system), whereas instructions that tell the computer how to run programs are referred to as software.
Flash memory is a type of non-volatile memory commonly used in microcontrollers. It uses floating-gate transistors, one of which is shown in FigureΒ 2.6.1. CG stands for control gate, and is where control signals are asserted. FG stands for floating gate, and is where electrons are either injected or removed to store data. S stands for source, which is generally the low potential (or ground) connection of a transistor. D is the drain, which is generally the high potential connection of a transistor.
The modes of operation of the flash floating-gate cell are detailed below.
-
Clear: High-voltage (>VCC) applied to
CG, channel on, electrons travel from S to D and in the process they tunnel through oxide toFG. -
Read: VCC applied to
CG, ifFGhas electrons, a channel will not form (read value = 0), ifFGhas no electrons, a channel will form (read value = 1) from S to D.
Flash ROM is a subset of EEPROM (electrically erasable programmable ROM). Today, there is little difference between EEPROM and flash memory.
