Home / Learn Chip Programming / Memory: Registers, SRAM, DRAM, Flash and EEPROM
Memory: Registers, SRAM, DRAM, Flash and EEPROM
A chip has many kinds of memory. Each one trades speed, size, cost and whether it keeps data without power.
Theory in plain words
What it is
Memory stores bits. Volatile memory loses its contents when power is removed (RAM). Non-volatile memory keeps it (Flash, EEPROM, ROM).
Why we use it
No single memory is fast, large, cheap and permanent. Chips combine several kinds in a hierarchy so programs run fast and data survives power off.
How it works
The CPU asks for a value at an address. The memory returns the byte stored there. Address lines choose the location, data lines carry the value, control lines say read or write.
Where it is used
- Microcontroller: Flash holds your program, SRAM holds variables, EEPROM holds settings
- PC and phone: registers, cache, DRAM, SSD
- FPGA: block RAM and LUT RAM
Comparison
| Type | Volatile? | Speed | Cell | Typical use |
|---|---|---|---|---|
| Register | yes | fastest | flip-flops | CPU working values |
| SRAM | yes | very fast | 6 transistors | microcontroller RAM, cache |
| DRAM | yes (needs refresh) | fast | 1 transistor + 1 capacitor | PC and phone main memory |
| ROM / Mask ROM | no | fast read | fixed at the factory | boot code |
| Flash (NOR) | no | fast read, slow write | floating gate | program memory |
| Flash (NAND) | no | dense, block erase | floating gate | SSD, SD cards, USB sticks |
| EEPROM | no | slow write | floating gate, byte erase | small settings and calibration |
Memory map: everything has an address
On a microcontroller the CPU sees one address space. Flash, SRAM and peripheral registers each live in a different address range. Reading address 0x20000000 on an STM32 reads SRAM. Writing 0x40020014 changes a GPIO register.
| Address range (STM32F1 example) | What is there |
|---|---|
| 0x0800 0000 | Flash memory (your code) |
| 0x2000 0000 | SRAM (variables and stack) |
| 0x4000 0000 | Peripheral registers (GPIO, UART, timers) |
| 0xE000 0000 | Core peripherals (SysTick, interrupt controller) |
Read and write a byte memory
Write 72, 105 at addresses 0 and 1: you stored the ASCII letters "H" and "i". Memory is just numbers; the meaning comes from how the program uses them.
Quick quiz
1. Which memory keeps data without power?
Flash is non-volatile.
2. Where does your program normally live on a microcontroller?
Code is stored in Flash; variables use SRAM.
Common questions
Which memory keeps data without power?
Flash. Flash is non-volatile.
Where does your program normally live on a microcontroller?
Flash. Code is stored in Flash; variables use SRAM.