LESSONMicrocontrollers · Part 6EP.85 · 24 s

MMIO vs PMIO: how the CPU talks to the pins

// WHAT YOU WILL LEARN

Memory-mapped I/O reaches registers with normal memory instructions; port-mapped I/O uses a separate I/O space with its own instructions; the AVR in an Uno does both (IN/OUT/SBI vs LD/ST). Follower request (@antonis_aggouridis).

// LESSON NOTES

Part 2 for you, @antonis_aggouridis 🔥 How does the CPU talk to a pin?

1️⃣ MMIO — memory-mapped I/O: the pins (GPIO, timers, UART…) sit at normal memory addresses, right next to RAM. The CPU uses the same load / store instructions for both. Most microcontrollers work this way: ARM (STM32, Raspberry Pi Pico), ESP32, RISC-V.

2️⃣ PMIO — port-mapped I/O: the pins get their own separate I/O space, and the CPU needs special IN / OUT instructions to reach it. Classic example: x86 PCs.

3️⃣ Your Arduino Uno (AVR) does BOTH! PORTB is I/O port 0x05 (reach it with IN / OUT / SBI) AND data address 0x25 (reach it with LD / ST / STS). Same register, two doors.
Fun fact: PORTB |= (1 << 5); compiles to sbi 0x05, 5 — one fast 2-cycle instruction that lights the LED on pin 13.

Same pins, two doors. 🚪🚪

Read the voiceover (transcript)
  1. How does the CPU talk to a pin?
  2. Memory-mapped I O: pins sit at memory addresses, just like RAM.
  3. Port-mapped I O: pins get their own space, with special in and out instructions.
  4. Your Uno does both! PORTB is port five, or memory address hex two five.
  5. Same pins, two doors!
  6. Next: the Pico board! Follow for Lesson seven!

Related lessons