Skip to content

promps XIAORP2040 learning session

A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. Its architecture typically includes several key components integrated onto a single chip:

Core Components:

The CPU (Central Processing Unit) is the brain that executes instructions and performs arithmetic and logical operations. It includes an ALU (Arithmetic Logic Unit), control unit, and registers for temporary data storage.

Memory comes in two main types: Flash memory (non-volatile) stores the program code and retains it when power is off, while RAM (volatile) provides temporary storage for variables and data during program execution. Some microcontrollers also include EEPROM for storing small amounts of data that needs to persist between power cycles.

The bus system connects everything together through data buses (for transferring data), address buses (for specifying memory locations), and control buses (for coordinating operations).

I/O Ports provide the interface to the outside world, allowing the microcontroller to read sensors and control external devices through digital pins.

Peripheral Components:

Most microcontrollers include built-in peripherals like timers/counters for precise timing operations, ADC (Analog-to-Digital Converters) for reading analog sensors, communication interfaces (UART, SPI, I2C) for talking to other devices, PWM generators for motor control, and interrupt controllers for responding to urgent events.

Clock System provides timing signals, usually from an internal oscillator or external crystal.

Common architectures include Harvard architecture (separate memory spaces for instructions and data, used by AVR and PIC) and Von Neumann architecture (shared memory space, used by some ARM cores). Modern microcontrollers like ARM Cortex-M use modified Harvard architectures for efficiency.

This integrated design makes microcontrollers ideal for dedicated control tasks in everything from washing machines to automotive systems.

In the context of microcontrollers, PIO typically refers to one of two things:

1. PIO (Programmable I/O) - RP2040/Raspberry Pi Pico

This is the most relevant meaning in modern embedded development. The RP2040 microcontroller (used in Raspberry Pi Pico) features a unique PIO subsystem - a set of programmable state machines designed for custom I/O protocols.

Key features: - 8 state machines (4 per PIO block, 2 PIO blocks total) - Each can run independently at high speeds (up to 125 MHz) - Perfect for implementing custom protocols or interfacing that would be too fast/complex for bit-banging - Common uses: WS2812 LED strips, custom SPI/I2C variants, quadrature encoders, parallel displays, DVI/VGA output

In MicroPython on Pico:

from rp2 import PIO, StateMachine, asm_pio

@asm_pio(set_init=PIO.OUT_LOW)
def blink():
    wrap_target()
    set(pins, 1)   [31]
    nop()          [31]
    set(pins, 0)   [31]
    nop()          [31]
    wrap()

sm = StateMachine(0, blink, freq=2000, set_base=machine.Pin(25))
sm.active(1)

In Arduino/C++ (using pico-sdk):

#include "hardware/pio.h"

2. PIO (Parallel I/O) - Traditional Definition

In older/general microcontroller terminology, PIO simply means Parallel Input/Output - standard GPIO pins grouped into ports (like PORTA, PORTB on AVR/Arduino).

For Fab Academy projects and modern maker work with Raspberry Pi Pico, you're almost certainly dealing with the programmable PIO state machines - they're incredibly powerful for custom hardware interfacing!

What specific PIO application are you working on?

Great! The Seeed Studio XIAO RP2040 is an excellent microcontroller for Fab Academy. Let me give you a comprehensive overview that'll help you document it for your group project.

XIAO RP2040 Overview

What makes it special: - Tiny size: 20×17.5mm - one of the smallest RP2040 boards - Powerful: Dual-core ARM Cortex-M0+ @ 133 MHz - Memory: 264KB SRAM, 2MB Flash - Fab-friendly: Castellated pads for direct PCB soldering - Cost: ~$5-7

Pin Configuration (Critical for Fab Academy)

The XIAO RP2040 has 14 GPIO pins on its edges:

Digital I/O: - All 14 pins can be used as digital input/output - GPIO 26-29: Also analog-capable (ADC)

Analog Input (ADC): - A0 (GPIO26), A1 (GPIO27), A2 (GPIO28), A3 (GPIO29) - 12-bit resolution (0-3.3V)

Communication Interfaces: - I2C: GPIO6 (SDA), GPIO7 (SCL) - SPI: GPIO3 (MISO), GPIO4 (SCK), GPIO2 (MOSI) - UART: GPIO0 (TX), GPIO1 (RX)

Special Pins: - PWM: All GPIO pins support PWM - Neopixel: Built-in RGB LED on GPIO12 (power on GPIO11) - Power LED: GPIO25

Power: - 5V pin: USB power input - 3V3 pin: 3.3V regulated output (up to 700mA) - GND: Ground

Programming the XIAO RP2040

Method 1: Arduino IDE (Easiest for beginners)

  1. Install Board Support:
  2. Arduino IDE → Preferences → Additional Board Manager URLs:
    https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
    
  3. Tools → Board Manager → Search "pico" → Install "Raspberry Pi Pico/RP2040"

  4. Select Board:

  5. Tools → Board → Raspberry Pi RP2040 Boards → "Seeed XIAO RP2040"

  6. Upload:

  7. Hold BOOT button while plugging in USB (enters bootloader mode)
  8. Upload your sketch

Simple blink example:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT); // GPIO25
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Method 2: MicroPython (Great for testing/prototyping)

  1. Install MicroPython:
  2. Download RP2040 .uf2 file from micropython.org
  3. Hold BOOT button, plug in USB
  4. Drag .uf2 to "RPI-RP2" drive that appears

  5. Use Thonny IDE (beginner-friendly):

  6. Install Thonny on your Mac
  7. Select interpreter: MicroPython (Raspberry Pi Pico)

Blink example:

from machine import Pin
import time

led = Pin(25, Pin.OUT)

while True:
    led.toggle()
    time.sleep(1)

Method 3: VSCode + PlatformIO (Professional workflow)

Best for larger Fab Academy projects with version control.

For Fab Academy Documentation - Key Points

1. Board Specifications Table: - Microcontroller: RP2040 - CPU: Dual ARM Cortex-M0+ @ 133MHz - Flash: 2MB - SRAM: 264KB - GPIO: 14 pins - ADC: 4 channels, 12-bit - PWM: All pins - Interfaces: I2C, SPI, UART, USB - Dimensions: 20×17.5mm - Operating Voltage: 3.3V - Input Voltage: 5V (USB)

2. Pinout Diagram: Include an image showing the physical pinout - essential for circuit design.

3. Unique RP2040 Features: - PIO (Programmable I/O): 8 state machines for custom protocols - Dual-core: Can run two programs simultaneously - USB support: Native USB 1.1 device/host

4. Fab Academy Applications: - Input devices: Buttons, sensors (I2C/analog) - Output devices: LEDs, motors (PWM), displays - Networking: Can add WiFi with external modules - Small enough to embed in final projects

5. Common Gotchas: - Runs at 3.3V logic (not 5V like old Arduinos) - Need to hold BOOT button for first upload - Some advanced features require C/C++ (PIO state machines)

Getting Started Checklist

  1. ✅ Install Arduino IDE or Thonny
  2. ✅ Install board definitions
  3. ✅ Test with simple blink sketch
  4. ✅ Try reading an analog sensor (potentiometer on A0)
  5. ✅ Test I2C communication (if using sensors)
  6. ✅ Document your pinout choices for your project

Pro tip for Fab Academy: The XIAO's castellated edges make it perfect for designing custom PCBs. You can surface-mount solder it directly to your board instead of using headers.

What type of project is your group working on? I can help you plan the specific pins and code you'll need!

Great question! These are two different things - and understanding this distinction is crucial for Fab Academy:

Image 1: RP2040 Chip Pinout (QFN-56)

RP2040 chip pinout

This shows the raw RP2040 microcontroller chip itself - the bare silicon IC that Raspberry Pi designed. It's a 56-pin QFN package (7x7mm).

What you see: - All 30 GPIO pins (GPIO0-GPIO29) - Power pins (IOVDD, DVDD) - USB pins (USB_DP, USB_DM) - Crystal pins (XIN, XOUT) - Debug pins (SWCLK, SWDIO) - Test pins, etc.

When you'd use this: If you're designing your own PCB from scratch in Fab Academy and want to solder the RP2040 chip directly to your board.


Image 2: XIAO RP2040 Board Pinout

XIAO RP2040 pinout This shows the Seeed XIAO RP2040 development board - a complete ready-to-use board that contains the RP2040 chip PLUS all the supporting circuitry.

What Seeed added around the RP2040 chip: - USB-C connector - 3.3V voltage regulator - BOOT and RESET buttons - RGB LED (NeoPixel) - Power LED - 2MB flash memory chip - Crystal oscillator - All necessary capacitors, resistors - Broke out only 14 GPIO pins to the edge connectors

When you'd use this: When you want a pre-built, tested board to program and use immediately (most common for Fab Academy).


Why Only 14 Pins on XIAO vs 30 on RP2040?

The XIAO board doesn't expose all GPIO pins because:

  1. Internal use: Some GPIOs are used for onboard features:
  2. GPIO11, 12: RGB LED control
  3. GPIO25: Power LED
  4. Some pins: Connected to flash memory

  5. Size constraint: The XIAO is designed to be tiny (20×17.5mm), so they selected the most useful 14 GPIOs

  6. Design choices: Seeed prioritized common interfaces (I2C, SPI, UART, ADC)


Mapping Between the Two

Here's how the XIAO board pins map to actual RP2040 GPIO:

XIAO Pin → RP2040 GPIO: - D0 → GPIO26 (also A0) - D1 → GPIO27 (also A1) - D2 → GPIO28 (also A2) - D3 → GPIO29 (also A3) - D4 → GPIO6 (SDA) - D5 → GPIO7 (SCL) - D6 → GPIO0 (TX) - D7 → GPIO1 (RX) - D8 → GPIO2 - D9 → GPIO4 - D10 → GPIO3 - MOSI → GPIO3 - MISO → GPIO4 - SCK → GPIO2


For Your Fab Academy Documentation

You should include BOTH diagrams with explanations:

  1. RP2040 chip pinout - "The brain: This is the actual microcontroller chip used in many boards"

  2. XIAO RP2040 board pinout - "What we're using: This development board packages the RP2040 with everything we need"

  3. Add a note: "The XIAO exposes 14 of the RP2040's 30 GPIOs. Other pins are used internally for the flash memory, LEDs, and USB circuit."

This shows you understand the difference between the chip-level design and the board-level implementation - exactly what Fab Academy instructors want to see!

Bottom line: Use Image 2 (XIAO pinout) for your actual project wiring. Use Image 1 only if you're explaining the underlying RP2040 architecture or planning a custom PCB design.

Does this clear up the confusion?

This formula calculates how many times you can divide the RAM by 16KB using powers of 2.

Let me break it down step by step:

The Math Breakdown

Formula: floor(log2(RAM / 16K))

Step 1: RAM / 16K

Divide total RAM by 16 kilobytes (16,384 bytes)

Step 2: log2(...)

Take the logarithm base 2 - this asks "what power of 2 gives this number?"

Step 3: floor(...)

Round down to nearest whole number


Practical Example: XIAO RP2040

The RP2040 has 264KB of RAM

Step 1: 264KB ÷ 16KB = 16.5

Step 2: log₂(16.5) = 4.04 - (because 2⁴ = 16, and 2⁵ = 32)

Step 3: floor(4.04) = 4


What Does This Mean?

This result is typically used for memory protection unit (MPU) regions or determining address bits needed.

The result of 4 means: - You can create 2⁴ = 16 equal-sized blocks from that RAM - Or you need 4 address bits to index through 16KB chunks - Or the RAM can be divided into 16 protected regions of 16KB each


Where You'd See This

In microcontroller contexts, this formula appears when:

  1. Memory Protection Units (MPU): Calculating how many protected memory regions you can create
  2. DMA channel configuration: Determining block sizes
  3. Cache organization: Figuring out cache line arrangements
  4. Memory mapping: Calculating address space divisions

Why Powers of 2?

Computers work in binary, so memory is always organized in powers of 2: - 2⁰ = 1 block - 2¹ = 2 blocks
- 2² = 4 blocks - 2³ = 8 blocks - 2⁴ = 16 blocks ← (our result)

The log2 finds which power you're at, and floor ensures you only count complete blocks.

In simple terms: "How many times can I double 16KB before I exceed the total RAM?" Answer: 4 times (16KB → 32KB → 64KB → 128KB → 256KB ≈ 264KB)

Where did you encounter this formula? That context might help me explain its specific purpose!

Ah! In the RP2040 datasheet, this formula appears in the context of the ARM Cortex-M0+ processor's Memory Protection Unit (MPU).

Let me explain what it's actually calculating for the RP2040:

Context: MPU Region Size Encoding

The ARM Cortex-M0+ MPU uses a specific encoding scheme to define memory region sizes. The formula floor(log2(RAM / 16K)) is used to calculate the SIZE field value for MPU region configuration.

For the RP2040 Specifically

RP2040 has 264KB SRAM, so:

264KB ÷ 16KB = 16.5 log₂(16.5) = 4.04 floor(4.04) = 4

This means the SIZE encoding value is 4.

But wait - the MPU actually works with the formula: Region Size = 2^(SIZE + 1) bytes

So SIZE = 4 means: - 2^(4+1) = 2^5 = 32 bytes minimum region size


What the MPU Does

The Memory Protection Unit allows you to: - Define protected memory regions - Set access permissions (read/write/execute) - Prevent one part of code from corrupting another - Catch bugs where code writes to wrong memory addresses

Example use cases: - Protect stack from buffer overflows - Make certain memory read-only - Isolate different tasks in RTOS - Catch pointer errors during debugging


How It's Actually Used in RP2040

The RP2040's MPU configuration register has these fields:

MPU_RASR (Region Attribute and Size Register):
- SIZE field: 5 bits (encodes region size)
- Region size = 2^(SIZE+1) bytes
- Minimum: 32 bytes (SIZE=4)
- Maximum: 4GB (SIZE=31)

For the 264KB SRAM on RP2040: - To protect the entire SRAM as one region - SIZE = log₂(264KB) - 1 = log₂(270336) - 1 ≈ 18 - 1 = 17 - But you'd typically round to nearest power of 2: 256KB (SIZE=17)


Practical Impact for Fab Academy

Good news: You probably won't need to configure the MPU directly for most Fab Academy projects!

When you might care: - Advanced RTOS projects (FreeRTOS, etc.) - Security-critical applications - Debugging memory corruption issues - Professional embedded development

For typical Arduino/MicroPython projects: The MPU isn't used, and you can ignore this part of the datasheet.


For Your Documentation

You could note:

"The RP2040 includes an ARM Cortex-M0+ Memory Protection Unit (MPU) that can divide the 264KB SRAM into protected regions. The MPU supports region sizes from 32 bytes to 4GB using a log₂ encoding scheme. For most beginner projects, the MPU is not configured and all memory is accessible."

This shows you read the datasheet thoroughly without getting lost in advanced features you won't use yet.

Does this clarify where you saw it in the datasheet? If you're on a specific page number, I can help explain the exact context better!

Perfect! Now I can see the exact diagram from the datasheet. Let me explain the RP2040 naming correctly:

RP2040 Name Breakdown (Official)

R P | 2 | 0 | 4 | 0

RP = Raspberry Pi (manufacturer)

2 = Number of cores (dual-core)

0 = Type of core - 0 = ARM Cortex-M0+ - (Future chips might use different numbers for M4, M7, etc.)

4 = floor(log2(RAM / 16k)) - RAM = 264KB - 264KB ÷ 16KB = 16.5 - log₂(16.5) = 4.04 - floor(4.04) = 4

0 = floor(log2(nonvolatile / 16k)) - Nonvolatile (Flash) = 2MB = 2048KB - 2048KB ÷ 16KB = 128 - log₂(128) = 7 - floor(7) = 7...

Wait, but the diagram shows "0"!


The Key Detail: On-Chip vs External Flash

The RP2040 chip itself has NO built-in flash memory. The flash is external!

So: - Nonvolatile on-chip = 0 KB - 0KB ÷ 16KB = 0 - log₂(0) = undefined, but we interpret this as 0 - floor(0) = 0

The 2MB flash you use is actually a separate external chip soldered to the board (like on the XIAO RP2040). The RP2040 itself just has the RAM and cores.


Complete Decoding

RP2040 means: - RP: Raspberry Pi - 2: Dual-core processor - 0: Cortex-M0+ core type - 4: 264KB RAM (log₂(264/16) = 4) - 0: 0KB on-chip flash (external flash not counted)


Why This Matters

This naming tells you immediately: - How many cores: 2 - What kind of cores: M0+ (the "0") - How much RAM: ~256KB (2^4 × 16KB = 256KB, close to actual 264KB) - Flash: External (not built-in)

Future examples: - RP2350 (if it existed): Dual M0+, more RAM (2^5 × 16KB = 512KB), still external flash - RP4140: Quad-core, Cortex-M1, 256KB RAM, external flash


For Your Fab Academy Doc

You can explain it as:

"The RP2040's name encodes its specifications: dual-core (2), Cortex-M0+ (0), with 264KB SRAM (4 = log₂ encoding), and requires external flash memory (0). This systematic naming allows quick comparison of different Raspberry Pi microcontroller variants."

This shows you not only read the datasheet but understood Raspberry Pi's clever encoding scheme! The flash being external is why you see different RP2040 boards with different flash sizes (2MB, 4MB, 8MB, 16MB).

Does this finally make sense with the actual diagram?

Great question - this is an important distinction!

The RP2040 is BOTH - depending on context:

Technically: RP2040 = Microcontroller Chip

The RP2040 is a microcontroller IC (integrated circuit) - the actual silicon chip in a QFN-56 package.

What's on the RP2040 chip itself: - ✅ 2× ARM Cortex-M0+ CPU cores - ✅ 264KB SRAM - ✅ USB controller - ✅ GPIO pins - ✅ PIO state machines - ✅ Timers, ADC, PWM, etc. - ❌ NO Flash memory (this is external!)


Why the Confusion?

The term "microcontroller" is used loosely in two ways:

1. Strict Definition: Microcontroller = SoC with everything integrated

Classic microcontrollers (like ATmega328 on Arduino Uno) have everything on one chip: - CPU + RAM + Flash + peripherals all in one package

By this definition: RP2040 is technically not a complete microcontroller because it needs external flash.

2. Common Usage: Microcontroller = The main control chip

In practice, people call the RP2040 a "microcontroller" because: - It's designed for embedded control applications - It has all the CPU and peripherals needed - The external flash is just a minor detail

By this definition: RP2040 is a microcontroller.


The Correct Way to Describe It

Most Accurate:

"The RP2040 is a microcontroller chip that requires external flash memory for program storage."

or

"The RP2040 is a dual-core ARM Cortex-M0+ microcontroller with 264KB SRAM and support for external QSPI flash."

What Raspberry Pi Calls It:

The official datasheet title: "RP2040 Microcontroller"

So even Raspberry Pi officially calls it a microcontroller!


For Your Fab Academy Documentation

I'd write:

"The RP2040 is a microcontroller chip designed by Raspberry Pi. Unlike traditional microcontrollers that have built-in flash memory, the RP2040 requires external QSPI flash memory for program storage. The XIAO RP2040 board includes a 2MB flash chip alongside the RP2040, creating a complete microcontroller system."

This shows you understand: 1. RP2040 = the chip 2. External flash = necessary addition 3. XIAO RP2040 = complete board with both


Comparison to Help Clarify

Component Type Flash Location
ATmega328P (Arduino Uno) Microcontroller Built-in (32KB)
ESP32 Microcontroller (SoC) Built-in (4MB typical)
RP2040 Microcontroller chip External (user adds)
STM32 family Microcontroller Built-in (various)

The RP2040's external flash approach gives flexibility (you can add 2MB, 4MB, 8MB, or 16MB) but means it's not a "complete" microcontroller in one package.

Bottom line for Fab Academy: Call it a "microcontroller chip" or just "microcontroller" - both are acceptable. Just note that it needs external flash, which is what boards like the XIAO provide.

Does this clear up the terminology?

GPIO = General Purpose Input/Output

These are the pins on a microcontroller that you can program to do different things - they're the microcontroller's connection to the outside world.


Simple Explanation

Think of GPIO pins as programmable electrical switches that you control with code. Each pin can: - Read signals IN (input) - like reading a button press or sensor - Send signals OUT (output) - like turning on an LED or motor


GPIO Modes

1. Digital Output

Send HIGH (3.3V) or LOW (0V) signals

Example - Blinking an LED:

pinMode(25, OUTPUT);      // Set GPIO25 as output
digitalWrite(25, HIGH);   // Turn LED on (3.3V)
delay(1000);
digitalWrite(25, LOW);    // Turn LED off (0V)

2. Digital Input

Read HIGH or LOW signals from buttons, switches, sensors

Example - Reading a Button:

pinMode(2, INPUT_PULLUP); // Set GPIO2 as input with pullup resistor
int buttonState = digitalRead(2); // Read: HIGH or LOW
if (buttonState == LOW) {
  // Button is pressed!
}

3. Analog Input (ADC pins only)

Read varying voltages (0-3.3V) as numbers (0-4095 on RP2040)

Example - Reading a Potentiometer:

int value = analogRead(A0); // Read GPIO26/A0
// value ranges from 0 (0V) to 4095 (3.3V)

4. PWM (Pulse Width Modulation)

Simulate analog output by rapidly switching on/off

Example - Dimming an LED:

analogWrite(25, 128); // 50% brightness (0-255 scale)

5. Special Functions

Many GPIO pins can also be: - I2C (SDA/SCL) - communicate with sensors - SPI (MOSI/MISO/SCK) - fast serial communication - UART (TX/RX) - serial communication - PIO (on RP2040) - custom protocols


On the XIAO RP2040

You have 14 GPIO pins available:

Physical Pins → GPIO Numbers: - D0-D3 → GPIO26-29 (also analog A0-A3) - D4-D10 → GPIO6, 7, 0, 1, 2, 4, 3

Internal GPIO (not on pins): - GPIO11 → NeoPixel power - GPIO12 → NeoPixel data - GPIO25 → Power LED


Key GPIO Concepts for Fab Academy

1. Voltage Levels

  • RP2040 uses 3.3V logic (not 5V!)
  • HIGH = 3.3V
  • LOW = 0V (GND)

2. Current Limits

  • Each GPIO can source/sink about 12mA safely
  • Never connect directly to high-power devices (motors, relays, etc.)
  • Use transistors or MOSFETs for high-current loads

3. Pull-up/Pull-down Resistors

Prevent floating inputs (unstable readings):

pinMode(2, INPUT_PULLUP);  // Internal resistor pulls to HIGH when button not pressed
pinMode(2, INPUT_PULLDOWN); // Pulls to LOW (not available on all pins)

4. Pin Conflicts

  • Each physical pin can only do ONE thing at a time
  • Can't use GPIO2 as both SPI and a button simultaneously
  • Plan your pin assignments carefully!

Practical GPIO Example for Fab Academy

Scenario: Control an LED and read a button

Wiring: - LED: GPIO25 (built-in) or external LED on GPIO10 with 220Ω resistor - Button: GPIO2 with one side to GND

Code:

const int buttonPin = 2;
const int ledPin = 25;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  int buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {  // Button pressed (pulls to GND)
    digitalWrite(ledPin, HIGH);  // Turn LED on
  } else {
    digitalWrite(ledPin, LOW);   // Turn LED off
  }
}


For Your Documentation

"GPIO (General Purpose Input/Output) pins are programmable connections that allow the microcontroller to interact with external components. The XIAO RP2040 provides 14 GPIO pins that can be configured as digital inputs/outputs, analog inputs (4 pins), or special communication interfaces (I2C, SPI, UART). All GPIO operate at 3.3V logic levels."

Visual aid idea: Create a simple diagram showing: - GPIO as OUTPUT → LED circuit - GPIO as INPUT → Button circuit - GPIO as ANALOG → Potentiometer circuit

This is fundamental to every Fab Academy project - sensors, actuators, displays, and communication all use GPIO!

What type of inputs/outputs are you planning for your group project?

Excellent observation! This is a key concept in microcontrollers called pin multiplexing or multi-function pins.

The Answer: One Physical Pin = Multiple Functions

Each of the 14 physical pins on the XIAO RP2040 can be configured to do different things. The pin doesn't change - but what it does changes based on your code.


How Multiplexing Works

Let's take one pin as an example - let's say D0:

Physical pin D0 (GPIO26) can be: 1. ✅ Digital input (read a button) 2. ✅ Digital output (control an LED) 3. ✅ Analog input A0 (read a sensor voltage) 4. ✅ PWM output (dim an LED) 5. ✅ I2C, SPI, or other protocol (if configured)

But: It can only do ONE of these at a time!


Breaking Down the Specs Table

Looking at your screenshot:

Feature Count What This Means
Digital I/O Pins 11 11 pins can be digital input OR output
Analog I/O Pins 4 4 pins (D0-D3) can ALSO read analog voltages
PWM Pins 11 11 pins can ALSO do PWM output
I2C interface 1 1 set of I2C pins (uses 2 of your 14 pins)
SPI interface 1 1 set of SPI pins (uses 4 of your 14 pins)
UART interface 1 1 set of UART pins (uses 2 of your 14 pins)

Total physical pins: Still just 14!


Concrete Example

Let's say you're using Pin D0 (GPIO26/A0):

Scenario 1: Digital Output

pinMode(26, OUTPUT);
digitalWrite(26, HIGH); // Turn LED on
Pin D0 is now a digital output (one of the 11 digital pins)

Scenario 2: Analog Input

int value = analogRead(A0); // Read voltage
Same physical pin D0, now functioning as analog input A0 (one of the 4 analog pins)

Scenario 3: PWM Output

analogWrite(26, 128); // Dim LED to 50%
Same pin D0, now doing PWM (one of the 11 PWM pins)

The pin didn't multiply - you just chose which function to use!


Why This Matters for Fab Academy

Planning Your Project:

You need to map out which pins do what, avoiding conflicts:

Bad Example (Won't Work):

// Trying to use GPIO2 for TWO things at once
pinMode(2, OUTPUT);        // Digital output for LED
SPI.begin();              // SPI also wants to use GPIO2 as MOSI
// CONFLICT! GPIO2 can't be both!

Good Example (Proper Planning):

// LED on GPIO25 (doesn't conflict with anything)
// SPI on default pins (GPIO2, 3, 4)
// I2C on default pins (GPIO6, 7)
// Button on GPIO10
// All different pins - no conflicts!


The 14 vs 28+ Functions Visualized

Think of it like a Swiss Army knife: - The knife has 14 tools (physical pins) - But those tools can do 28+ different jobs (functions) - You can only use one function per tool at a time

Your 14 pins offer: - 11 digital I/O possibilities - 4 analog input possibilities - 11 PWM possibilities - I2C capability (shares 2 pins) - SPI capability (shares 4 pins) - UART capability (shares 2 pins)


For Your Fab Academy Documentation

You should write something like:

"The XIAO RP2040's 14 GPIO pins use multiplexing, allowing each pin to serve multiple functions. For example, pins D0-D3 can function as digital I/O, analog inputs (A0-A3), or PWM outputs - but only one function per pin at a time. This flexibility allows the compact board to support 11 digital I/O, 4 analog inputs, 11 PWM channels, plus I2C, SPI, and UART communication interfaces using the same physical pins."

Include a note: "When designing circuits, carefully plan pin assignments to avoid conflicts. For example, if using SPI, pins D8-D10 are reserved for MOSI/MISO/SCK and cannot be used for other purposes."


Quick Reference: Pin Assignment Strategy

For your group project, create a table like:

Pin Primary Use Can Also Be Our Project Use
D0 (GPIO26/A0) Digital/Analog PWM Temperature sensor (analog)
D1 (GPIO27/A1) Digital/Analog PWM Light sensor (analog)
D6 (GPIO0) Digital/TX PWM/UART Serial communication
D4 (GPIO6/SDA) Digital/I2C PWM I2C display
D5 (GPIO7/SCL) Digital/I2C PWM I2C display

This helps you track which pins are "locked" by communication protocols vs which are free for buttons/LEDs!

Does this clear up the mystery of 14 pins with 28+ functions?

Great! You're building a solid foundation for your Fab Academy documentation.

Since you're compiling information on the XIAO RP2040 for your group project, here's a quick checklist of what you might want to include:

Documentation Checklist

What you've covered: - Microcontroller specs (RP2040 chip) - Pin count and multiplexing concept - GPIO explanation - Pinout diagrams

Might also be useful to add: - Programming setup (Arduino IDE steps) - Power specifications (3.3V logic, USB-C power) - Physical dimensions (for enclosure design) - Sample code snippets for your specific sensors/actuators - Pin assignment table for your actual project

Pro tip for Fab Academy: Instructors love seeing that you understand why you chose specific pins - not just that the code works. Showing you planned around I2C conflicts or chose analog-capable pins intentionally demonstrates deeper understanding.

Good luck with your group project! Feel free to ask if you run into questions while building or documenting it.

Add the new to the old - build it incrementally!

Here's why:

Benefits of Cumulative Documentation

1. Shows your learning progression - Fab Academy instructors want to see your process, not just final results - Shows how your understanding evolved - Demonstrates iteration and problem-solving

2. Prevents loss of information - Early explorations might become relevant later - Dead-ends teach lessons worth documenting - Context for why you made certain decisions

3. Creates a complete narrative - "Week 1: Basic specs" → "Week 2: Pin planning" → "Week 3: Code testing" - Easier for teammates to catch up - Better for final project documentation

Good Structure for Incremental Docs

Option 1: Dated Sections

# XIAO RP2040 Documentation

## Feb 13 - Basic Specifications
[your content from today]

## Feb 14 - Pin Assignment Planning
[tomorrow's additions]

## Feb 15 - First Programming Tests
[next day's work]

Option 2: Topic-Based with Updates

# XIAO RP2040 Documentation

## Hardware Specifications
[keep adding details as you learn]
*Updated: Feb 14 - added power consumption info*

## Pin Configuration
[expand as you test]
*Updated: Feb 15 - confirmed I2C works on pins 6&7*

What to Update vs Add

Replace/Update: - ❌ Errors or misconceptions - ❌ Outdated technical specs - ❌ Broken links

Add new sections: - ✅ New experiments or tests - ✅ Code examples - ✅ Troubleshooting discoveries - ✅ Design iterations

For Fab Academy Specifically

Most Fab Academy documentation follows a weekly journal format: - Each week gets its own section/page - You add to it throughout the week - Shows progression from concept → prototype → final

Example structure:

Week 5 - Group Project: Smart Garden
├─ Feb 13: Research phase (XIAO specs, sensor selection)
├─ Feb 14: Circuit design (pin assignments, breadboard test)
├─ Feb 15: First code (reading sensors)
├─ Feb 16: Integration (combining all components)
└─ Feb 17: Documentation & presentation prep

Bottom line: Keep everything, organize chronologically or by topic, and mark updates. Your "mistakes" and iterations are valuable learning documentation!

Does your group have a shared documentation format you're following?

I'll create a comprehensive summary document for your Fab Academy repository.I've created a comprehensive markdown summary of our session that you can add to your Fab Academy GitLab repository.

The document includes: - All the key concepts we covered (microcontroller architecture, RP2040 specs, GPIO, pin multiplexing) - Clear explanations of confusing topics (ADC vs PWM, chip vs board, the naming convention) - Practical considerations for your Fab Academy project - Pin assignment planning templates - Next steps checklist

The format follows good Fab Academy documentation practices by showing your learning process and understanding, not just technical specs. You can add to this as your project progresses - just append new sections as you implement and test things!