Update Time:2026-03-31

Best Memory for Microcontroller: Complete Selection Guide

Best memory for microcontrollers: Flash, SRAM, EEPROM, external memory options, selection guide by application, and recommendations for embedded systems.

Network & Communication

Best Memory for Microcontroller

Introduction

Choosing the right memory for a microcontroller project depends on your application's code size, data retention requirements, speed needs, and power constraints. Modern microcontrollers integrate multiple memory types—Flash for program storage, SRAM for runtime variables, and EEPROM/Flash for non-volatile data—while complex projects may require external memory expansion using SPI Flash, I²C EEPROM, or SDRAM. This comprehensive guide explains the different memory types available for microcontrollers, compares internal versus external memory options, provides specific recommendations by application type (IoT, data logging, real-time systems, etc.), and helps you select the optimal memory configuration for your embedded project.


Memory Types Overview

Internal Memory Types

1. Flash Memory (Program Storage)

Function: Stores firmware/application code

Characteristics:

Type: Non-volatile (retains data without power)
Size: 16KB - 2MB (typical MCU range)
Speed: Slower than SRAM (100-200 MHz read, seconds to write)
Endurance: 10,000-100,000 write cycles
Cost: Low (integrated in MCU)

Read: Fast (single-cycle in some MCUs)
Write: Slow (page-based, milliseconds)
Erase: Block-based (sectors of 512B-4KB)

Use Cases:

  • Firmware storage (bootloader, application code)
  • Constant data (lookup tables, graphics, fonts)
  • Non-volatile configuration storage

2. SRAM (Static RAM - Runtime Memory)

Function: Stores variables, stack, heap during program execution

Characteristics:

Type: Volatile (data lost on power-off)
Size: 2KB - 512KB (typical MCU range)
Speed: Very fast (CPU clock speed, 0-wait-state)
Endurance: Unlimited read/write cycles
Cost: Moderate (more expensive per byte than Flash)

Access time: Nanoseconds (instant)
Power: Higher static power consumption than Flash

Use Cases:

  • Global variables
  • Function call stack
  • Dynamic memory allocation (malloc/heap)
  • Buffers for data processing

3. EEPROM (Electrically Erasable Programmable ROM)

Function: Stores small amounts of non-volatile data

Characteristics:

Type: Non-volatile
Size: 512B - 16KB (typical MCU range)
Speed: Slow write (milliseconds), fast read
Endurance: 100,000 - 1,000,000 cycles (byte-level)
Cost: Moderate

Write granularity: Byte-level (unlike Flash)
Erase: Not required (can overwrite directly)

Use Cases:

  • Configuration parameters (WiFi credentials, calibration data)
  • User settings
  • Counters that must survive power loss
  • Product serial numbers

External Memory Options

1. External Flash (SPI/QSPI/Parallel)

Popular ICs:

  • Winbond W25Q128 (SPI, 16MB, ~$1.50)
  • Micron MT25Q (QSPI, 128MB, ~$8)
  • Cypress S25FL (Quad SPI, 256MB, ~$12)

When to Use:

  • Code storage exceeds internal Flash
  • Large data logging requirements (>1MB)
  • Firmware update staging area
  • Multimedia storage (audio, images)

2. External EEPROM (I²C/SPI)

Popular ICs:

  • Microchip 24LC256 (I²C, 32KB, ~$0.50)
  • Microchip 25LC512 (SPI, 64KB, ~$1)
  • STMicroelectronics M95M02 (SPI, 256KB, ~$2)

When to Use:

  • Configuration data larger than internal EEPROM
  • Separate non-volatile storage from program Flash
  • Multiple configuration profiles
  • Data that changes frequently (wear leveling)

3. External SRAM (SPI/Parallel)

Popular ICs:

  • Microchip 23LC1024 (SPI, 128KB, ~$2)
  • ISSI IS62WV51216 (Parallel, 1MB, ~$4)
  • Cypress CY62148 (Parallel, 512KB, ~$3.50)

When to Use:

  • Insufficient internal SRAM for buffers
  • Large frame buffers (graphics displays)
  • Audio processing buffers
  • Fast temporary storage

4. SD Card / eMMC

When to Use:

  • Massive data logging (MB-GB scale)
  • Removable storage for data retrieval
  • File system requirements (FAT32, exFAT)
  • Field data collection devices

Internal vs External Memory

Decision Matrix

FactorInternal MemoryExternal Memory
SpeedFastest (0-wait)Slower (SPI: 1-20 MB/s)
CostIncluded in MCUAdditional $0.50-$20
PCB SpaceNoneRequires footprint + traces
PowerLower (integrated)Higher (separate IC + I/O)
CapacityLimited (KB-MB)Expandable (MB-GB)
ReliabilityHigher (fewer components)Lower (more failure points)
DevelopmentSimpler (no drivers)Complex (SPI/I²C drivers needed)

When to Use Internal Memory Only

✅ Suitable Applications:

  • Simple sensors (temperature, humidity readers)
  • LED controllers
  • Motor control
  • Small IoT devices with cloud connectivity
  • Real-time control systems
  • Battery-powered devices (power critical)

Requirements:

  • Code size <500KB
  • RAM requirements <64KB
  • Minimal data logging
  • Low BOM cost critical

When to Add External Memory

✅ Justifiable Applications:

  • Data loggers (environmental, vehicle, industrial)
  • Audio players/recorders
  • Graphics displays (>320×240)
  • Firmware-over-the-air (FOTA) updates
  • Machine learning inference (model storage)
  • Digital cameras/sensors with image storage

Indicators:

  • Code/data exceeds 80% of internal memory
  • Need removable storage (SD card)
  • Frequent configuration changes (wear EEPROM)
  • Large buffers required (>64KB)

Best Memory by Application

IoT Devices (Connected Sensors)

Recommended Configuration:

Internal Memory:

Flash: 256KB - 512KB
  - Bootloader: 16-32KB
  - Application: 128-256KB
  - OTA update staging: 128KB (optional, or use external)

SRAM: 32KB - 64KB
  - WiFi/BLE stack: 16-32KB
  - Application buffers: 8-16KB
  - TCP/IP stack: 8KB

EEPROM: 1-4KB
  - WiFi credentials: 128B
  - Device configuration: 512B
  - Calibration data: 256B

External Memory (if needed):

SPI Flash (W25Q32, 4MB, ~$0.80):
  - OTA update storage
  - Local data caching before cloud upload
  - Offline operation buffer

Example MCU:

  • ESP32-C3 (4MB Flash, 400KB SRAM) - WiFi/BLE built-in
  • STM32L4 (512KB Flash, 128KB SRAM) - Low power
  • nRF52840 (1MB Flash, 256KB SRAM) - BLE + Thread

Data Logging (Environmental Monitoring)

Recommended Configuration:

Internal Memory:

Flash: 128KB - 256KB (code)
SRAM: 16KB - 32KB (buffers)

External Memory (required):

SPI Flash (W25Q128, 16MB, ~$1.50):
  - Ring buffer for 24-48hr data
  - Wear leveling across sectors
  - Write in page-sized chunks (256B)

OR SD Card (via SPI/SDIO):
  - 1GB+ capacity
  - FAT32 file system
  - Removable for data retrieval

Data Management:

Strategy: Batch writes to Flash
- Buffer in SRAM: 512B-1KB
- Write to Flash when buffer full
- Timestamp each entry
- Circular buffer overwrites oldest data

Example MCU:

  • Arduino-compatible (ATmega328P + external Flash/SD)
  • STM32F1 (128KB Flash, 20KB SRAM) + SD card
  • ESP8266 (4MB Flash built-in, sufficient for moderate logging)

Real-Time Control Systems

Recommended Configuration:

Internal Memory (prioritize speed):

Flash: 64KB - 256KB
  - Deterministic code execution
  - Minimal interrupt latency

SRAM: 16KB - 64KB
  - Control loop variables: 4-8KB
  - Input buffers (ADC): 2-4KB
  - Output buffers (PWM): 2-4KB
  - Real-time OS (if used): 8-16KB

NO EXTERNAL MEMORY (avoid latency)

Key Requirement: Deterministic timing—external memory access introduces variable latency

Example MCU:

  • STM32F4 (512KB Flash, 192KB SRAM) - 168 MHz, FPU
  • TI TM4C (256KB Flash, 32KB SRAM) - ARM Cortex-M4F
  • Infineon XMC4000 - Industrial control optimized

Multimedia Applications (Audio/Display)

Recommended Configuration:

Internal Memory:

Flash: 512KB - 2MB
  - Graphics library: 64-128KB
  - Audio codec: 32-64KB
  - Application: 128-256KB

SRAM: 128KB - 512KB
  - Frame buffer: 320×240×2 bytes = 150KB (RGB565)
  - Audio buffer: 4-16KB (DMA ping-pong)
  - Graphics workspace: 32KB

External Memory (often required):

External SRAM (Parallel, 512KB-1MB):
  - Frame buffer (faster than SPI)
  - Large graphics buffers

QSPI Flash (128MB):
  - Audio files (MP3, WAV)
  - Image assets (JPEG, BMP)
  - Font libraries

Example MCU:

  • STM32H7 (2MB Flash, 1MB SRAM) - 480 MHz, graphics accelerator
  • iMX RT1060 (external Flash via FlexSPI) - 600 MHz, graphics
  • ESP32-S3 (8MB PSRAM option) - Built-in audio/display features

Machine Learning Inference

Recommended Configuration:

Internal Memory:

Flash: 512KB - 2MB
  - TensorFlow Lite model: 100KB-1MB
  - Inference runtime: 64-128KB

SRAM: 128KB - 512KB
  - Model weights (if not quantized): 256KB
  - Activation buffers: 64KB
  - Input data: 16-32KB

External Memory:

QSPI Flash (16-128MB):
  - Model storage (load to RAM at startup)
  - Multiple model versions
  - Training data (if on-device learning)

Example MCU:

  • STM32H7 (AI optimized, optional external SDRAM)
  • Nordic nRF5340 (1MB Flash, 512KB SRAM)
  • ESP32-S3 (8MB Flash, 512KB SRAM + 8MB PSRAM)

Memory Selection Decision Tree

Step 1: Estimate Code Size

< 64KB → Low-end MCU (ATmega, STM32F0)
64-256KB → Mid-range (STM32F1, ESP8266)
256-512KB → High-end (STM32F4, ESP32)
> 512KB → Premium (STM32H7, i.MX RT) or external Flash

Step 2: Estimate RAM Requirements

< 8KB → 8-bit MCU (AVR, PIC)
8-32KB → Entry ARM (Cortex-M0+, M3)
32-128KB → Mainstream (Cortex-M4)
128KB+ → High-performance (Cortex-M7) or external SRAM

Step 3: Non-Volatile Data Needs

< 1KB → Internal EEPROM sufficient
1-32KB → External EEPROM (I²C/SPI)
> 32KB → SPI Flash or SD card

Step 4: Performance Requirements

Real-time critical → Internal memory only
Moderate speed OK → SPI external memory acceptable
Bulk storage → SD card + file system

Top Recommendations

Budget IoT ($2-5 MCU)

ESP8266 (Built-in 4MB Flash)

  • Flash: 4MB (integrated)
  • SRAM: 80KB
  • WiFi built-in
  • Cost: ~$2
  • Best for: WiFi sensors, home automation

General Purpose ($3-8 MCU)

STM32F103 (Blue Pill)

  • Flash: 64-128KB
  • SRAM: 20KB
  • Add: 24LC256 EEPROM (I²C, 32KB, $0.50) if needed
  • Cost: ~$3 + external memory
  • Best for: General embedded projects

High Performance ($8-15 MCU)

STM32F4 Series

  • Flash: 512KB - 1MB
  • SRAM: 128-192KB
  • Add: W25Q128 (SPI Flash, 16MB, $1.50) if needed
  • Cost: ~$8-12 + external memory
  • Best for: Advanced applications, DSP

Premium / AI ($15-25 MCU)

STM32H7 Series

  • Flash: 2MB
  • SRAM: 1MB
  • Optional: External SDRAM, QSPI Flash
  • Cost: ~$15-25
  • Best for: Graphics, ML inference, multimedia

Conclusion

The best memory for your microcontroller project depends on application requirements: simple IoT sensors thrive on integrated Flash/SRAM/EEPROM (ESP8266: 4MB Flash, 80KB SRAM), data loggers benefit from external SPI Flash or SD cards (W25Q128: 16MB, $1.50), real-time control demands internal-only memory for deterministic timing, and multimedia applications require high-capacity MCUs with optional external SRAM/Flash (STM32H7: 2MB Flash, 1MB SRAM). Start with internal memory, add external storage only when capacity or cost-effectiveness demands it.

Key Takeaways:

Internal memory types: Flash (code), SRAM (variables), EEPROM (settings)
Flash sizing: 4-16KB (simple), 32-128KB (moderate), 256KB+ (complex)
SRAM needs: 2-8KB (basic), 16-64KB (mainstream), 128KB+ (graphics/ML)
External Flash: Best for data logging, firmware updates (W25Q128: 16MB, $1.50)
External EEPROM: Configuration data >internal capacity (24LC256: 32KB, $0.50)
SD card: Massive logging (GB scale), removable storage
Real-time: Internal memory only (avoid external access latency)
Budget: ESP8266/ESP32 (integrated 4-8MB Flash) excellent value

Designing embedded systems? Visit AiChipLink.com for microcontroller selection, memory configuration, and embedded system design consultation.

 

 

 

 


 

AiCHiPLiNK Logo

Written by Jack Elliott from AIChipLink.

 

AIChipLink, one of the fastest-growing global independent electronic   components distributors in the world, offers millions of products from thousands of manufacturers, and many of our in-stock parts is available to ship same day.

 

We mainly source and distribute integrated circuit (IC) products of brands such as BroadcomMicrochipTexas Instruments, InfineonNXPAnalog DevicesQualcommIntel, etc., which are widely used in communication & network, telecom, industrial control, new energy and automotive electronics. 

 

Empowered by AI, Linked to the Future. Get started on AIChipLink.com and submit your RFQ online today! 

 

 

Frequently Asked Questions

What type of memory do microcontrollers use?

Microcontrollers use Flash for program storage, SRAM for runtime data, and EEPROM for persistent settings, with optional external memory for expansion.

How much Flash memory do I need?

Flash requirements range from a few KB for simple tasks to 2MB+ for complex applications, and it’s best to choose at least 2× your estimated code size.

Is SRAM or DRAM used in microcontrollers?

SRAM is used in microcontrollers because it is faster, simpler, and does not require refresh like DRAM.

What is the best external memory for data logging?

SPI Flash suits moderate data, SD cards handle large storage, and I²C EEPROM is ideal for small, infrequent writes.

Can I add more RAM to a microcontroller?

Yes, you can add external SRAM (SPI or parallel), but using an MCU with more built-in RAM is usually more efficient.