Architecture and Hardware

What is a bus in embedded systems?

A bus is a shared set of signal lines that moves data between a processor, memory and peripherals. See how address, data and control buses, AHB/APB and I2C fit in.

On this page
  1. The short answer
  2. The three parts of a classic system bus
  3. Bus width, speed and bandwidth
  4. Buses inside a microcontroller
  5. Bus masters, slaves and arbitration
  6. External and peripheral buses
  7. Bus topologies
  8. Why buses matter when you write firmware
  9. Bus vs interface vs protocol

The short answer

In embedded systems, a bus is a shared communication pathway, a set of wires or on-chip signal lines plus the rules for using them, that carries data between components such as the processor, memory and peripherals.

Instead of wiring every component directly to every other one, components attach to a common bus and take turns using it. A microcontroller has internal buses linking its CPU core to flash, RAM and peripherals. Outside the chip, buses such as I2C, SPI and CAN connect it to sensors, memory chips and other devices.

The three parts of a classic system bus

The textbook model of a processor’s system bus has three groups of signals.

Address bus

The address bus carries the location the processor wants to read or write. It usually flows one way, from the processor (or another bus master) to memory and peripherals. Its width sets how many locations can be addressed: a 16-bit address bus can reach 65,536 locations (64 KB of byte-addressed memory), and a 32-bit address bus can reach 4 GB.

Data bus

The data bus carries the values being read or written. It’s bidirectional. Its width, such as 8, 16, 32 or 64 bits, sets how much data moves in one transfer. This is part of what people mean by an “8-bit” or “32-bit” microcontroller, though that label usually refers to the CPU’s register and data-path width.

Control bus

The control bus carries signals that coordinate each transfer: whether it’s a read or a write, when the address and data are valid, the clock, wait or ready signals, interrupt requests, and reset. These signals turn a collection of wires into an orderly exchange.

Together, a transfer looks like this: the processor puts an address on the address bus, signals “read” on the control lines, and the selected memory or peripheral places the value on the data bus.

Bus width, speed and bandwidth

A bus’s bandwidth, how much data it can move per second, depends roughly on its width and clock rate. A 32-bit bus that completes one transfer per clock at 100 MHz could in theory move 400 MB/s. Real throughput is lower, because some transfers need extra cycles (wait states) when the target, such as flash memory, can’t keep up with the bus clock.

Buses inside a microcontroller

Inside a modern microcontroller, the “bus” is usually a set of interconnected buses running at different speeds.

Arm AMBA buses: AHB, APB and AXI

Most Arm-based chips use Arm’s AMBA bus specifications:

  • AHB (Advanced High-performance Bus): a faster bus connecting the CPU core, flash, SRAM, DMA controllers and high-speed peripherals.
  • APB (Advanced Peripheral Bus): a simpler, slower, lower-power bus for peripherals such as UART, I2C, SPI and timers. It connects to the AHB through a bridge.
  • AXI (Advanced eXtensible Interface): a higher-performance bus used in more powerful processors and larger systems-on-chip.

That’s why STM32 reference manuals, for example, talk about peripherals sitting on “AHB1”, “APB1” or “APB2”. Each bus has its own clock settings, which limits how fast the peripherals on it can run.

Bus matrix and multiple masters

Many microcontrollers connect their buses through a bus matrix (or interconnect), which lets different masters reach different targets at the same time. The CPU can fetch instructions from flash while a DMA controller copies ADC results into SRAM, as long as they aren’t competing for the same target.

Processor architecture affects bus design too. Some cores use separate paths for instructions and data, which is the subject of our article on Harvard vs von Neumann architecture.

Bus masters, slaves and arbitration

Devices on a bus play one of two roles:

  • A master (also called an initiator, controller or manager) starts transfers. Examples: the CPU, a DMA controller, a USB or Ethernet controller with its own DMA.
  • A slave (also called a target, peripheral or subordinate) responds to transfers. Examples: SRAM, flash, peripheral registers.

When two masters want the same bus or target at once, an arbiter decides who goes first, using fixed priorities, round-robin or other schemes. External buses that allow several masters need arbitration too. I2C and CAN do it with clever electrical tricks, covered in the arbitration section of our embedded communication protocols guide.

External and peripheral buses

Outside the chip, buses connect the microcontroller to other components.

Parallel buses send many bits at once over many wires. Examples include the external memory interfaces some microcontrollers offer for connecting SRAM, NOR flash or LCD controllers, and older 8-bit LCD data buses. They’re fast but use many pins.

Serial buses send bits one at a time over a few wires, and they dominate modern embedded design:

  • I2C: two wires, many addressed devices on one board.
  • SPI: fast, with a chip-select line per device.
  • CAN: robust multi-node bus for vehicles and machines.
  • RS-485: differential multi-drop bus for industrial cabling.
  • USB: a host-controlled bus with a tiered-star layout.
  • 1-Wire and LIN: low-cost, low-speed buses for simple devices.

Not every serial link is a bus. A UART connection between two devices is point-to-point, so it’s usually called an interface or port rather than a bus.

Bus topologies

  • Shared (multi-drop) bus: many devices on the same lines, as with I2C, CAN and RS-485. This saves wiring, but devices must share bandwidth and avoid talking over each other.
  • Point-to-point: one link between exactly two devices, as with a UART connection. No addressing needed.
  • Star or switched: devices connect through a hub or switch, as with USB hubs and switched Ethernet.

Why buses matter when you write firmware

Even if you never design a bus, its behaviour shows up in your code:

  • Memory-mapped registers. Peripherals appear at addresses in the processor’s address space. Writing to a peripheral register is a bus write to that address, which is why register access in C uses pointers to fixed addresses, marked volatile so the compiler doesn’t optimize the access away.
  • Peripheral clock enables. On many microcontrollers, a peripheral’s clock on its bus must be enabled before its registers respond. Forgetting this is a classic “my peripheral does nothing” bug.
  • Clock limits. A peripheral’s maximum speed often depends on its bus clock, so a UART on a slower APB bus may not reach the same baud rates as one on a faster bus.
  • Wait states. At higher CPU speeds, flash needs extra wait states, set in a configuration register. Getting this wrong can crash the chip right after you raise the clock.
  • DMA contention. Heavy DMA traffic can slow the CPU’s accesses to the same memory, which can matter for timing-critical code.
  • Bus faults. Accessing an invalid address triggers a fault. On Arm Cortex-M3 and above, that’s a BusFault exception, which escalates to a HardFault if not enabled. Fault handlers and status registers help track down the culprit.

For the memories at the other end of these buses, see our guide to microcontroller memory types.

Bus vs interface vs protocol

These terms overlap, but roughly:

  • A bus is a shared pathway that several devices attach to.
  • An interface is the connection point between two components: the pins, signals and electrical characteristics. It may or may not be shared.
  • A protocol is the set of rules for communicating over a bus or interface: timing, framing, addressing, error handling.

I2C, for instance, is all three: a bus (shared SDA and SCL lines), an interface (the pins and electrical rules) and a protocol (start conditions, addresses, acknowledgements). For how buses fit into the overall design of a device, see our embedded system architecture guide.

The complete guide to architecture and hardware

Embedded System Architecture: Hardware and Software Components
Read the guide

Keep exploring

Guides from other topics

All topics →