DEV Community

Hedy
Hedy

Posted on

How does a microprocessor communicate with peripherals?

A microprocessor communicates with peripherals through a combination of data buses, address buses, control signals, and specific I/O techniques. The goal is to send data, receive input, and control external devices like sensors, displays, keyboards, and communication modules.

Image description

Main Components Involved

Image description

Communication Methods
1. Memory-Mapped I/O (MMIO)
Used by ARM (e.g., STM32), MIPS, RISC-V

  • Peripherals are assigned memory addresses
  • CPU uses normal instructions to access them (e.g., LDR, STR in ARM)
  • Example: 0x40020000 could be a GPIO register
c

#define GPIO_DATA (*(volatile unsigned int *)0x40020000)
GPIO_DATA = 0xFF;  // Send data to GPIO
Enter fullscreen mode Exit fullscreen mode

2. Port-Mapped I/O (PMIO)
Used by Intel x86 (e.g., 8086)

  • Peripherals are in a separate I/O space
  • Accessed with special instructions like IN, OUT
asm

mov dx, 0x03F8  ; COM1 serial port
mov al, 'A'
out dx, al      ; Send character to peripheral
Enter fullscreen mode Exit fullscreen mode

Data Transfer Mechanisms

Image description

Control Signals Used

Image description

Visual Overview:

css

           ┌────────────────────────┐
           │      Microprocessor    │
           └──────┬────┬────┬───────┘
                  │    │    │
         ┌────────▼────▼────▼────────┐
         │  Address  Data  Control   │   ← Buses
         └────────┬────┬────┬────────┘
                  │    │    │
      ┌───────────▼┐  ┌▼───────────┐
      │  Memory    │  │ Peripheral │ ← (e.g., GPIO, UART, LCD)
      └────────────┘  └────────────┘
Enter fullscreen mode Exit fullscreen mode

Summary

Image description

Top comments (0)