Skip to content
Home
Microcontrollers: Architecture, Peripherals, and Selection Guide

Microcontrollers: Architecture, Peripherals, and Selection Guide

Embedded Systems Embedded Systems 8 min read 1526 words Beginner ExcellentWiki Editorial Team

What Is a Microcontroller?

A microcontroller (MCU) is a single-chip computer that integrates a processor core, memory, and programmable I/O peripherals on a single silicon die. Unlike a microprocessor that requires external RAM, ROM, and peripheral controller chips, a microcontroller has everything needed for embedded control applications integrated into one package. According to IC Insights, the microcontroller market shipped over 30 billion units annually, with ARM Cortex-M devices accounting for the largest share of 32-bit MCU shipments. The integration reduces cost, board space, power consumption, and design complexity, making MCUs the ideal choice for the vast majority of embedded systems.

Popular MCU Families

ARM Cortex-M dominates professional embedded development with devices from STMicroelectronics (STM32 series with over 1,200 part numbers covering Cortex-M0 through M7), NXP (LPC and i.MX RT series with integrated power management and advanced connectivity), Microchip (SAMD and SAME series integrating Cortex-M0+ through M4), and Renesas (RA series with robust security features). The AVR architecture from Microchip powers the Arduino ecosystem and remains popular for education and simple projects. PIC microcontrollers maintain a strong presence in industrial applications because of their long-term availability guarantees (often 15+ years), robust peripheral set, and ease of use for simple control tasks. ESP32 from Espressif Systems integrates Wi-Fi and Bluetooth into a dual-core Xtensa LX6 or LX7 MCU at a price point under $3, making it the dominant platform for IoT applications. RISC-V is emerging as an open-source instruction set architecture with the E907, GD32V, and other cores gaining traction in cost-sensitive Asian markets where ARM licensing fees are a significant factor.

Core Components

CPU Core

The central processing unit fetches instructions from program memory and executes them in a pipelined sequence. ARM Cortex-M cores feature the Nested Vectored Interrupt Controller (NVIC) that provides deterministic interrupt handling with latency as low as 6 CPU cycles and supports up to 240 interrupt sources with programmable priority levels. Most MCUs use a modified Harvard architecture with separate buses for program memory and data memory, allowing simultaneous instruction fetch and data access to improve throughput. CPU clock speeds range from 32.768 kHz in ultra-low-power wristwatch applications to over 600 MHz in high-performance crossover MCUs like the NXP i.MX RT1170 that bridges the gap between MCUs and application processors.

Memory Types

Flash memory stores the program code and constant data, with typical sizes from 16 KB in tiny 8-bit MCUs used for simple sensor interfaces to 2 MB in high-end 32-bit devices running complex communication stacks and RTOS applications. SRAM holds runtime data including global variables, the call stack, and heap allocations, typically ranging from 2 KB to 512 KB. EEPROM provides non-volatile byte-addressable storage for configuration parameters, calibration data, and device serial numbers, typically up to 64 KB. Some modern MCUs incorporate additional memory types such as Tightly Coupled Memory (TCM) that provides single-cycle access for time-critical code and data, and Quad-SPI (QSPI) interfaces for executing code from external Flash at high speed.

GPIO

General Purpose Input/Output pins are the primary interface between the MCU and external circuitry. Each pin can be configured through the GPIO peripheral registers as a digital input with optional pull-up or pull-down resistors that prevent floating inputs, a digital output in push-pull mode (actively drives HIGH or LOW) or open-drain mode (pulls LOW only, requires external pull-up for HIGH), or an alternate function connected to an internal peripheral such as a UART TX line or timer output. GPIO toggle frequency depends on the AHB or APB bus clock speed; high-performance Cortex-M devices can typically toggle GPIO pins at up to 50 MHz, enabling bit-banged protocols for interfaces not available in hardware.

Peripheral Overview

Timers and Counters

Timers are among the most versatile MCU peripherals. Basic timers generate periodic interrupts for software timing and RTOS ticks. General-purpose timers produce PWM signals with adjustable frequency and duty cycle, measure input signal frequency and pulse width through capture channels, and count external events. Advanced timers support quadrature encoder interfaces for motor position sensing in robotics and CNC machines, complementary outputs with programmable dead-time insertion for driving H-bridge MOSFETs in motor control applications, and break input for emergency shutdown that immediately forces outputs to safe states. The STM32 TIM1 advanced timer exemplifies this with a 16-bit auto-reload counter, four independent capture/compare channels, complementary outputs, and synchronization across multiple timer instances.

Analog-to-Digital Converter

The ADC converts continuous analog voltages to discrete digital values for processing by the firmware. Resolution ranges from 10 bits (1024 levels, sufficient for basic sensor readings) through 12 bits (4096 levels, typical for general-purpose applications) to 16 bits (65,536 levels, required for precision measurement). Successive-approximation register (SAR) ADCs are most common, offering sampling rates from 10 kSPS to 5 MSPS with excellent power efficiency. The ADC can be configured for single conversion on demand, continuous conversion that repeatedly samples a single channel, scan mode that sequences through multiple channels automatically, and injected conversion triggered by external events or timer outputs that interrupts the current scan for a priority measurement — a feature documented extensively in STM32 reference manuals.

Communication Interfaces

UART provides asynchronous serial communication for simple point-to-point links with configurable baud rates up to 10 Mbps, commonly used for debug consoles, GPS modules, and Bluetooth modules. SPI offers synchronous full-duplex communication at speeds up to 50 MHz for connecting displays, ADCs, SD cards, and memory chips with minimal protocol overhead. I2C uses a two-wire bus with device addressing for moderate-speed communication with multiple devices on a shared bus, ideal for sensor networks. CAN (Controller Area Network) provides differential signaling with robust error detection for automotive and industrial networking at bit rates up to 1 Mbps.

DMA Controllers

Direct Memory Access (DMA) controllers transfer data between peripherals and memory without CPU intervention, freeing the processor for computation or allowing it to enter a low-power sleep state. A typical DMA controller manages 8–16 channels with configurable priority, transfer size (byte, half-word, word), and addressing modes (peripheral-to-memory, memory-to-peripheral, memory-to-memory). Typical applications include continuous ADC sampling at 1 MSPS with double-buffered memory, SPI display updates at 10 MHz that would otherwise consume 100% of CPU cycles, and UART communication at 1 Mbps with automatic receive buffering.

Selecting an MCU

Key selection criteria include processing power measured in DMIPS or CoreMark scores relative to your computational requirements, memory capacity for the application firmware plus a 30–50% safety margin for future features, peripheral set that matches the required external interfaces without needing external chips, power consumption in all operating modes (active, sleep, deep sleep) for battery life calculations, package size and pin count compatible with the PCB layout and assembly process, unit cost at the target production volume including any licensing fees, development tools quality including IDE, debug probe, and software libraries, ecosystem maturity including community forums, application notes, and third-party support, and supply chain stability with multiple sourcing options and guaranteed long-term availability.

Clock Sources

MCUs use multiple clock sources to balance performance and power. High-speed external crystals (8–25 MHz) provide accurate main CPU clock for precise timing. Low-speed external crystals (32.768 kHz) drive the real-time clock for accurate timekeeping in sleep modes. Internal RC oscillators provide immediate startup without external components at lower accuracy. Phase-locked loops (PLLs) multiply a lower-frequency source to generate higher CPU and peripheral clocks. Dynamic clock switching through the reset and clock control (RCC) peripheral allows runtime selection between sources to balance performance and power consumption.

Bootloader and Application Partitioning

Many MCU-based products partition Flash memory between a bootloader and the main application. The bootloader resides in a protected region of Flash (typically at the beginning of the memory map) and handles firmware updates over UART, USB, or wireless interfaces. The application occupies the remaining Flash space. The linker script allocates a fixed size for each region, and a reserved RAM region stores shared state such as update flags and reset cause. This architecture is essential for products that support field firmware updates.

Frequently Asked Questions

What is the difference between a microcontroller and a microprocessor? A microcontroller integrates CPU, memory, and peripherals on a single chip for embedded control. A microprocessor requires external RAM, ROM, and I/O controllers and is designed for general-purpose computing with an operating system.

How do I choose between ARM Cortex-M and RISC-V? ARM Cortex-M offers a mature ecosystem with extensive documentation, tools, and community support. RISC-V provides open-source core flexibility and lower licensing costs but with a less mature ecosystem and fewer off-the-shelf MCU options currently available.

What does Flash memory size affect? Flash determines the maximum program size. A simple sensor node may fit in 16–32 KB. A complex application with FreeRTOS, TCP/IP stack, and multiple drivers may require 512 KB or more.

Can a microcontroller run Linux? No. Microcontrollers lack the memory management unit required for standard Linux. Only microprocessors with MMUs can run Linux. For complex software, consider a dual-processor architecture with an MCU for real-time control and an MPU for Linux.

What is the significance of the NVIC in ARM Cortex-M? The Nested Vectored Interrupt Controller provides deterministic interrupt handling with automatic context saving, programmable priority levels for nesting, and hardware-vectored dispatch that eliminates software interrupt lookup overhead.

Related: Arduino Beginners Guide | ARM Cortex Guide

Section: Embedded Systems 1526 words 8 min read Beginner 756 articles in section Report inaccuracy Back to top