Hardware memory is used for storing information. In the case of embedded systems that may be the program data ,the program code itself, event logging etc. There are many types of technologies used when creating memory cells and many ways to categorize them, but we can distinguish two major categories based on the memory reaction to the removal of the power supply:

Volatile Memory

This type of memory requires power in order to retain its stored information. If the power supply is turned off the data is lost.

Volatile memory is used as:

  • Data Memory –  Storing the data segment, the heap and the stack of the program (see Memory Layout of Embedded C Programs)
  • Program Memory – If fast execution is needed the code segment can be moved from the non-volatile memory to the volatile during the reset vector execution.

Two of the most popular types of volatile memories are:

  • DRAM (Dynamic Random-Access Memory) – This type of volatile memory stores the information in capacitors. It is called “dynamic” because it requires periodical refreshing of the capacitors’ charge.  Each capacitor stores one bit. Due to the capacitors’ inherent leakage if there are no refresh cycles to recharge them, the stored information will be lost.
    • Advantages:
      • It is low-cost and suitable when high-capacity memory is required
    • Disadvantages:
      • Slower when compared to SRAM
  • SRAM (Static Random-Access Memory) – This type of volatile memory stores the information using transistor logic and it does not require any refresh cycles, hence its name “static”.
    • Advantages:
      • SRAM is typically faster than DRAM
      • Requires less power than DRAM
    • Disadvantages:
      • Complex structure which makes it more expensive than DRAM

Non-Volatile Memory (NVM)

This type of memory retains the stored information even when the power is removed. In embedded systems it is used for storing the code of the program and any other type of data that must be preserved when the power supply is switched off. Below is a list of the most popular types of NVM:

  • Mask ROM – This is a read-only non-volatile memory. The only write to the memory is performed in the factory during the manufacturing process of the ROM.  These types of memories due to their low cost are appropriate for embedded systems where large volumes will be produced. The major drawback is that update of the program stored in the memory is not possible.
  • PROM (Programmable Read-Only Memory) – This is a read-only non-volatile memory that can be written (programmed) only once. A special programming device has to be used for this purpose.
  • EPROM (Erasable Programmable Read-Only Memory) –  This memory can be electrically programmed, but erasing it requires physically exposing it to ultraviolet light.  Due to this specific it’s no longer used in embedded systems.
  • EEPROM (Electrically Erasable Programmable Read-Only Memory) – This type of memory can be electrically programmed and erased. The term EEPROM is commonly used for memories that can be erased in small chunks (e.g bytes). It has limited number of erase/write cycles (typical values ~100,000-1,000,000 cycles).
  • Flash –  Flash memory is a type of EEPROM. It is electrically erased in blocks (not single bytes) and reprogrammed in bytes or blocks. Flash memories have a limited guaranteed number of erase and write cycles (typical values ~10,000 – 100,000 cycles). It is the most used type of memory in embedded systems.
  • SSD (Solid State Disk) –  These type of storage devices are usually constructed using flash memories and are used in embedded systems for operating system storage, event logging etc.
  • SD Card (Secure Digital Card) – The main distinction of this type of memory compared to the other non-volatile memories is that  SD Card is portable by design. It supports SPI interface and provides a convenient data storage for embedded systems.