Labs / MicroPython tutorials

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial

Author: Li Zisheng · Source: FreakStudio open documentation, v1.2.0 · License: CC BY 4.0

Contents

1. Introduction to Raspberry Pi Pico

The Raspberry Pi Pico is a low-cost, high-performance microcontroller development board officially designed by Raspberry Pi, featuring flexible digital interfaces. In terms of hardware, it adopts the RP2040 microcontroller chip independently developed by Raspberry Pi, is equipped with an ARM Cortex-M0+ dual-core processor, has an operating frequency of up to 133MHz, integrates 264KB of SRAM and 2MB of memory, and also has up to 26 multifunctional GPIO pins on board.In terms of software, you can choose the C/C++ SDK provided by Raspberry Pi or use MicroPython for development. It comes with complete development materials and tutorials, which facilitates quick getting started with development and embedding applications into products.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.1 Front of the Raspberry Pi Pico Development Board
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.2 Back of the Raspberry Pi Pico Development Board

Differences between a development board and a chip:

  • What is a "chip"(taking RP2040 as an example): The RP2040 is a single electronic component, an integrated circuit independently developed by Raspberry Pi:
    • It serves as the core functional carrier of the Pico development board, and itself integrates core computing/storage modules including the ARM Cortex M0+ dual-core processor, 264KB SRAM, and 2MB flash memory;
    • However, the chip cannot function on its own: it is merely a packaged integrated circuit devoid of peripheral components such as power supply circuits, interfaces, and pin expansion. If you take the RP2040 chip alone, you can neither power it nor connect it to sensors or peripherals.
  • What is a "development board"(taking the Raspberry Pi Pico as an example): The Raspberry Pi Pico is a finished circuit board based on the RP2040 chip:
    • It is centered around the RP2040 chip, and integrates necessary peripheral circuits and interfaces at the same time: for example, it comes with an onboard USB power supply circuit, extends the chip's pins into 26 GPIO header pins, and is equipped with a BOOTSEL button, an LED indicator, a USB interface, etc. ;
    • It is a ready-to-use "finished tool": after developers get the Pico, they don't need to build basic circuits such as power supplies and pin expansions by themselves, and can directly connect it to a computer via USB and plug in sensors to start development.

1.1 Basic Parameters of the Pico Development Board

Plain-language Explanation of MCU Chip Parameters

  • Adopting the official RP2040 microcontroller chip from Raspberry Pi: it serves as the core computing unit of the development board, integrating all basic functional modules and acting as the "hardware foundation carrier" for the development board to realize computing and control functions.
  • Dual-core ARM Cortex M0+ processor with an operating frequency up to 133MHz and flexible clocking: is the computing core of the development board:
    • "Dual-core" means having 2 independent computing units that can process different tasks in parallel (e. g., simultaneously collecting sensor data + controlling peripherals);
    • The "133MHz clock" serves as the benchmark for computing speed — it can execute 133 million basic instructions per second, which sets the upper limit of task processing speed and meets the efficiency requirements of most lightweight control and Data Acquisition scenarios.
  • Built-in 264KB SRAM and 2MB on-chip Flash:
    • SRAM (264KB) serves as the "temporary data buffer" during program operation to store intermediate data generated during program execution, such as real-time values collected by sensors and temporary calculation results. With a capacity of 264KB, it can support scenarios of "simultaneously processing 3 to 5 channels of sensor data plus simple logical operations"; if a task requires processing a large amount of real-time data (e. g., multi-channel high-speed signal acquisition), an SRAM with a larger capacity should be considered.
    • On-chip Flash (2MB): Yes the "permanent storage area" for programs and fixed data, used to store user-written programs, predefined configuration parameters, etc. (data will not be lost after shutdown). The 2MB capacity can store dozens of lightweight control programs, or programs containing a small number of fixed creatives (such as simple character display data); if a large amount of offline data (such as screen display images) needs to be stored, external peripheral expansion storage is required.
  • Stamp hole design: it is the hardware integration interface of the development board, which can be directly soldered onto the circuit board independently designed by users to realize the "hardware integration" of the development board into the finished device.
  • USB 1.1 host and device support → serves as the USB communication interface of the development board and features a "dual-role" design:
    • As a "device": it communicates with the computer (host computer) to realize program download and data upload;
    • Act as a "host": connect external USB devices (such as USB flash drives, keyboards) to expand functions like data storage and human-computer interaction.
  • Supports low-power sleep and hibernation modes → which is the power management mechanism of the development board:
    • "Sleep Mode": Pauses non-essential modules, retains core data, and supports quick wake-up (applicable to short-term idle scenarios);
    • "Sleep Mode": Shuts down more hardware modules and retains only basic power supply, featuring lower power consumption (suitable for battery-powered scenarios with prolonged inactivity). This function is an essential support for portable, low-power devices.
  • Can be recognized as a mass storage device via USB for drag-and-drop program download: Yes A simplified method for program flashing: The development board emulates a "mass storage device" via USB, eliminating the need for dedicated flashing tools. Users only need to copy the program file to this "device" to complete the flashing process, significantly lowering the hardware/operation threshold for entry-level development.
  • Up to 26 multifunctional GPIO pins (23 digital pins; 3 analog ADC pins): serve as the universal interaction interface between the development board and external devices.
    • Digital pins: transmit discrete signals of "HIGH/LOW level" to control peripherals (such as LED on/off, motor start/stop) or read signals from digital sensors;
    • Analog ADC Pins: Convert external continuously varying analog signals (such as the voltage signal from a temperature sensor) into digital values to enable "gradual signal acquisition"(e. g., continuous measurement of temperature and brightness).
  • 2 SPIs, 2 I2Cs, 2 UARTs, 3 12-bit ADCs, and 16 controllable PWM channels → are the dedicated communication/control modules of the development board:
    • SPI/I2C/UART: are three commonly used "serial communication buses":
      • SPI: Suitable for high-speed short-distance communication (e. g., connecting displays and high-speed sensors);
      • I2C: supports multi-device bus sharing (e. g., connecting multiple temperature and humidity sensors simultaneously);
      • UART: It is a traditional serial communication interface (e. g. for connecting serial port modules, Bluetooth modules);
    • 12-bit ADC: it serves as the quantization unit for analog signals; a 12-bit configuration corresponds to 4096 quantization levels, and more levels lead to higher precision of the collected analog signals (for example, smaller numerical errors when measuring temperature);
    • 16 PWM channels: refer to the "Pulse Width Modulation modules", which adjust the duty cycle of pulses to realize "analog output"(such as continuously regulating motor speed and LED brightness), and multiple channels can simultaneously control different states of multiple devices.
  • Accurate on-chip clock and timer: as the time reference module of the development board, it provides high-precision time ticks for "timed task triggering"(e. g., periodic sensor data acquisition) and "signal duration measurement"(e. g., pulse signal decoding for infrared remote controls), serving as the core support for all time-related functions.
  • Built-in temperature sensor on chip: Yes On-chip environment monitoring unit: Capable of real-time monitoring of the chip's own temperature without external sensors, which can be applied to "chip over-temperature protection"(to prevent hardware damage) and "rough ambient temperature detection"(to replace simple external temperature sensors).
  • On-chip accelerated floating-point library: Yes Floating-point arithmetic optimization module: Improves the efficiency of "numerical calculation with decimals"(e. g., filtering and calibration algorithms for sensor data), avoids the precision loss of ordinary integer arithmetic, and reduces computation time simultaneously.
  • 8 programmable I/O (PIO) finite-state machines for custom peripheral support: are the hardware interface expansion unit of the development board: by programming to define the timing logic of pins, it can simulate non-standard peripheral interfaces (such as SD card read-write interface, VGA display interface), break through the limitations of the chip's native interfaces, and adapt to special peripherals.
  • 3-pin ARM Serial Wire Debug (SWD) port: it is the program debugging interface of the development board: with a dedicated debugging tool, it can read the chip's operating status and set breakpoints for program debugging, which is an essential hardware interface for troubleshooting program errors and optimizing code.
  • A simple yet highly flexible power architecture — the power management system of the development board: it supports two power supply modes, Micro-USB (for desktop development scenarios) and external power supply/battery (for portable device scenarios), adapts to different usage environments, and improves the scenario compatibility of hardware.

1.2 Pinout Diagram of Pico Development Board

The pinout diagram serves as the "external interface manual" for the Raspberry Pi Pico — when you want to connect external components such as LEDs and sensors to the Pico, randomly connecting pins may either result in incorrect power connection that burns out the hardware, or the selected pins may not support the functions required by the component (for example, if a sensor requires an analog signal but you choose a purely digital pin); referring to the pinout diagram allows you to clearly understand the function of each pin (whether it is a power pin, ground pin, or signal port) and the supported functions, which not only prevents equipment damage due to incorrect connections but also accurately fulfills requirements such as "lighting up an LED" and "enabling a sensor to transmit data".

First, let’s clarify: What exactly is a "pin"? The difference between chip pins and development board pins

  • What is a pin? A pin can be understood as the "external interface / connecting wire" of a development board — just like the charging port or headphone jack of a mobile phone, it serves as the "channel" that connects the development board to external electronic components (such as sensors and LED lights): it can not only receive power from an external source (power pins), but also transmit control or data signals (signal pins).
  • Difference between chip pins and development board pins:
    • Chip pins: These are the tiny metal contacts (small solder points on the chip surface) on the RP2040 chip itself. They are extremely small in size and can only be used after soldering, so ordinary users cannot directly connect wires to them;
    • Development board pins refer to the interfaces that the Pico forms by expanding the "chip pins" into easily pluggable header pins (i. e., the row of metal pins on the board). Users can directly insert DuPont wires into these pins to connect components such as sensors and motors without soldering by themselves.
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.3 Raspberry Pi Pico Development Board Pinout

You can first refer to the "legend" in the top-left corner (colors correspond to pin types: for example, red indicates power pins, and green indicates GPIO pins), then locate the pin numbers on the board (such as GP0 and GP25). The text next to each pin number (such as UART-TX and ADC0) denotes the pin's additional functions. Finally, based on the requirements of the component you are connecting (for instance, if you need 3.3V power supply, look for the red 3V3 pin; if you need analog signal input, look for the pin labeled ADC), match the colors in the legend with the function labels beside the pins, and you will find the appropriate pin.

The definitions of each pin are as follows:

  • VSYS: 2V~5V power input pin, which serves as the power supply input pin of the development board.
  • VBUS: It is a 5V power output obtained from the Micro USB interface, which can supply power to electronic components that require a 5V power supply.
  • 3V3 (OUT): 3.3V power supply, which matches the operating voltage of the Pico W. This pin can be used to power external circuits (the maximum output current depends on the RP2040 load and VSYS voltage; it is recommended to keep the load on this pin below 300 mA).
  • 3V3_EN: This pin controls the 3.3V power supply switch. It is set to "ON"(high level) by default. When a low level is input to this pin, the 3V3 (OUT) power output will be turned off, and part of the power supply to the Pico itself will also be controlled accordingly.
  • RUN: RUN is the enable pin of the RP2040 MCU chip, and you can enable or disable the Pico by applying a high or low level to the RUN pin.
    • By default, it is at a high level, and there is an internal (on-chip) pull-up resistor connected to 3.3V outside the pin, which has a resistance value of 50kΩ.
    • Applying a low input level will cause the Pico to stop operating and undergo a reset.
  • GP0 to GP28: These are general-purpose function interfaces, the most commonly used pins on the Pico, capable of connecting to a wide range of external components: they can either output signals (such as controlling the on/off of an LED) or input signals (such as reading data from sensors). The onboard LED is connected to the GP25 pin.
  • ADC0 to ADC2: These pins can function either as regular GPIO pins or as "analog input ports" — for example, to measure gradual signals such as temperature levels and light intensity (regular GPIO pins can only detect discrete "on/off" signals).
  • AGND: AGND (Analog Ground) is specifically used as the reference ground for analog signals such as those on GPIO26 to GPIO29, serving as the "reference ground line" for ADC (Analog-to-Digital Conversion). If you need to measure analog signals with high precision (for example, requiring a very small temperature measurement error), connect this pin to the ground line of external components; if high precision is not required, it can also be directly connected to the common digital ground line (GND).
  • ADC_VREF: ADC_VREF is the reference voltage pin for improving the accuracy of analog acquisition. By default, it uses the filtered voltage from the Pico's own 3.3V power supply. To achieve higher ADC measurement accuracy, you can connect an external, more stable reference voltage to this pin.

1.3 Pico Development Board Hardware Circuit

Beginners can think of the RP2040 chip as "a phone motherboard without a screen, battery or buttons" — it has core functions, but cannot work without these accessories. These hardware circuits supplement the chip with essential functions such as "power supply, clock, status indicator and interfaces", turning the Pico from a "bare chip" into a "ready-to-use development board".

RP2-B1 20/48 P65F44.00 RP2-B2 21/24 P65W87.00 RP2040

The Raspberry Pi Pico is equipped with some peripheral circuits of the RP2040 chip, including passive components such as an external Flash memory chip (W25Q16JV), a clock crystal oscillator, and power filter capacitors, as well as a USB connector, a reset button, and an LED indicator. Most of the available pins of the RP2040 chip are routed out on both sides of the Pico development board, and four pins are reserved for internal functions, including driving the onboard LED, powering the development board, and selecting the BOOT mode.

The schematic diagram of the Raspberry Pi Pico is shown below, which consists of an external clock crystal oscillator circuit, a BOOT mode selection circuit, a power supply input circuit, a power supply voltage measurement circuit, an LED indicator driving circuit, a debugging interface circuit, a pin expansion circuit and a chip peripheral circuit, and these will be introduced to you one by one next.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.4 Raspberry Pi Pico Development Board Circuit Schematic

Simply put, the peripheral circuits of a Pico development board consist of the following parts:

1.3.1 Power Supply Circuit

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.5 Power Supply Circuit Schematic

The Raspberry Pi Pico can be powered by an external power supply or a Micro-USB cable, and there are two power lines worth our attention:

The entire power voltage conversion is implemented by the RT6150B DC-DC power supply chip. The RT6150A/B is a high-efficiency, fixed-frequency switching power converter that operates with input voltages higher than, lower than, or equal to the output voltage. This chip features low static power consumption (the switching operating frequency is set to 1MHz, and the static current in power-saving mode is only 60μA), compact size, selectable operating modes (power-saving mode PSM enable control) and other advantages, and is commonly used in power supply modules for portable products and handheld instruments and meters.

Introduction to RT6150 Power Management IC

(1) Chip Parameters and Reference Circuit Design

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.6 RT6150 Power Chip Parameters and Reference Circuit Design

(2) PCB Routing Reference Diagram

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.7 RT6150 Power Chip PCB Layout Reference

Here, the GPIO23 pin of the Raspberry Pi Pico is connected to the PS pin of the power supply chip, and the operation mode of the power supply chip can be switched by controlling the high and low level output of GPIO23:

The RP2040 chip on the Raspberry Pi Pico requires two voltage supplies: 3.3V (for I/O) and 1.1V (for the digital core voltage of the chip). Since the RP2040 has an integrated 3.3V-to-1.1V LDO, there is no need to worry about the 1.1V power supply issue.

1.3.2 Clock Crystal Oscillator Circuit

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.8 Clock Crystal Oscillator Circuit

Chips cannot function without precise "timing rhythm" — for example, tasks like flashing an LED at 1-second intervals or transmitting data in sync with a sensor all rely on a stable "clock signal". This circuit serves as Pico's "external precision metronome", dedicated to providing a stable time reference for the RP2040. Below are its core components and their functions:

Here, a crystal oscillator with SMD3225-4P package and 12MHz frequency is selected. The 15pF capacitors on both sides of the crystal oscillator function to ensure more stable oscillation frequency, and a 1kΩ resistor connected in series in XOUT is used for current limiting, which can prevent the crystal oscillator from reduced service life or damage caused by over-driving. If other different crystal oscillators are selected, these values may need to be adjusted.

When strict timing requirements are not required, the clock of the RP2040 can be selected to be input from the internal oscillator.

1.3.3 BOOT Mode Selection Circuit

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.9 BOOT Mode Selection Circuit

This circuit incorporates two key functional modules of the Pico: one is the BOOT mode selection circuit that controls the "startup state", and the other is the Flash memory circuit that stores programs. The former helps you switch between the states of "running the stored program" and "loading a new program", while the latter acts as the "built-in small hard drive" for the Pico to store programs. Their specific functions are detailed as follows:

When the RP2040 is powered on, the QSPI_SS pin automatically defaults to pull-up, and the RP2040 checks the value of this I/O during the boot process; when QSPI_SS is at logic 0, the RP2040 enters the BootLoader mode of the boot loader driver.

There is a short period during power-up when the state of the QSPI_SS pin cannot be guaranteed, and this can be ensured by adding a pull-up resistor. For the W25Q128 Flash memory, an external pull-up resistor is unnecessary, so it is marked as NO-FIT and can be omitted during soldering.

Below is the Flash memory circuit, whose power supply operates at the same voltage as the 3.3V power pin of the chip. The pins of the W25Q128 are connected to the QSPIx pins of the RP2040. Place 2.2uF and 100nF filter capacitors near the power supply pin (VCC) of the W25Q128 Flash memory to provide a stable 3.3V power supply for the W25Q128JVSIQ.

The steps to flash firmware in USB mode are as follows:

  1. First, turn off the power supply of the circuit board.
  2. Hold down the start button while the circuit board is powered on (i. e., hold down the BOOTSEL button and then connect the USB)
  3. Pico will appear as a USB mass storage device, and you can complete the Flash writing by dragging a special '. uf2' file to the disk
  4. Unplug the USB connector of the Pico and then reconnect it

1.3.4 Power Supply Measurement Circuit

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.10 Power Supply Measurement Circuit

This circuit is the 'power supply voltage monitoring module' of Pico, which utilizes the ADC (analog signal acquisition) function of the chip to measure the supply voltage of Pico in real time (for example, checking the remaining power of the battery). First, understand the basics of the ADC of the RP2040, then look at the function of this circuit:

The ADC of the RP2040 is a "tool for measuring gradual change signals"(such as measuring voltage levels), and it has 5 acquisition channels:

These ADC pins are internally protected by reverse diodes and feature a 12-bit resolution (equivalent to dividing the 0~3.3V range into 4096 small steps for more accurate voltage measurement).

The so-called power supply measurement circuit is to use GPIO29 (corresponding to ADC3 channel) to measure the supply voltage (VSYS) of the Pico:

Finally, GPIO29 will sample the "divided VSYS voltage", and the current supply voltage can be obtained after conversion (for example, when powered by a battery, the battery level can be monitored).

1.3.5 Peripheral Circuit of the Chip

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.11 Chip Peripheral Circuit

The RP2040 chip serves as the "core brain" of the Pico, but it requires "supporting safeguards" to operate independently — the peripheral circuitry below acts as an "auxiliary module" that complements the chip with essential capabilities such as "communication, power supply, and anti-interference", enabling the chip to work stably and implement functions including USB connection and ADC acquisition, which are specifically divided into the following parts:

1.3.6 LED Driver Circuit

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.12 LED Drive Circuit

It is used to test the GPIO25 pin of the RP2040, and its on-off can be controlled via a program.

1.3.7 Debug Interface Circuit

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.13 Debug Interface Circuit

This circuit serves as Pico's "program debugging port" — when the program you wrote malfunctions (e. g. the board is unresponsive or functions incorrectly), it can help you troubleshoot issues and load code directly, offering more flexibility than regular USB programming. Its specific functions are detailed below:

There are two ways to reprogram the Flash on Pico:

Additionally:

1.3.8 Pin Expansion Circuit

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.14 Pin Expansion Circuit

The pins here are led out through 2 sets of "1×20Pin" stamp holes (each set has 20 pin holes), and the spacing between adjacent holes is 2.54mm — this is a common standard spacing for electronic components, compatible with regular DuPont wires and expansion boards.

The advantage of this design is its "dual-purpose" functionality: it can either be directly connected to components like sensors and LEDs via Dupont wires for experiments, or the Pico can be soldered onto a custom-designed circuit board, making it easy to integrate the Pico into your finished projects (such as small robots or environmental monitoring devices).

1.3.9 Introduction to Test Points

There are 6 test points (TP1 to TP6) accessible on the Raspberry Pi Pico:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 1.15 Raspberry Pi Pico Test Points (TP1~TP6) Function Description

These 'test points (TP1~TP6)' are the 'spare small connectors' reserved on the Pico board — the main interfaces such as Micro-USB and pins are sufficient for regular use, but when you need to batch test whether the development boards are functional, the main interfaces are damaged, or special operations are required, these test points can temporarily replace some functions. The functions of each test point are as follows:

2. Introduction to the RP2040 Chip

RP2040 is the first microcontroller chip launched by Raspberry Pi, featuring the advantages of low power consumption, high performance and low cost.

The RP2040 chip is manufactured using a 40nm process, which means the chip is compact in size and low in power consumption, and it comes in a 7×7mm QFN-56 package —that is, the chip is a 7mm square die with 56 small pins, making it easy to solder onto circuit boards:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.1 RP2040 Chip in QFN-56 Package: Photo and Dimensions

The specific specifications and parameters are as follows:

What is "encapsulation"?

The core of a chip (the integrated circuit on the silicon wafer) can be understood as a "fragile bare die" — it is thin and delicate, vulnerable to impacts and moisture, and has no directly connectable interfaces, making it impossible to use as-is. "Packaging" is the process of "fitting a protective casing and leading out interfaces" for this bare die:

  • It serves as the "protective casing" of a chip: it encloses the fragile core circuitry to resist impacts, moisture and dust, thereby preventing damage to the circuits;
  • It serves as the "external interface" of the chip: metal pins are drawn out from the core circuit to facilitate soldering the chip onto a circuit board, enabling the chip to receive power and transmit signals with external components.

Different packages feature distinct shapes and pin counts; for instance, the "7×7mm QFN-56 package" used for the RP2040: QFN denotes the package type (a flat no-leads form factor), 56 indicates that this package comes with 56 pins, and 7×7mm refers to the dimensional size of the package.

In addition to the QFN package used for the RP2040, these are other common chip packages:

  • DIP package (Dual In-line Package) Take "DIP-20" as an example: it features long metal pins arranged in two rows, which can be directly inserted into a breadboard or perforated prototype board.
    • Features: beginner-friendly, easy to insert and solder, and simple to disassemble when damaged; however, it is relatively bulky in size.
    • Applicable scenarios: Experiments for beginners, prototype verification on breadboards (for example, early 51 single-chip microcontrollers commonly used DIP packages).
  • SOIC package (Small Outline Integrated Circuit package) For example, "SOIC-16": it is a surface-mount package, with pins being small metal leads on the surface of the circuit board, and its volume is much smaller than that of DIP.
    • Features: Compact size, suitable for tight circuit board layouts; however, it requires surface-mount soldering, making manual soldering more difficult for beginners compared to DIP packages.
    • Applicable scenarios: Small consumer electronics (such as chips for Bluetooth modules and small sensors).
  • QFP package (Quad Flat Package) For example, "QFP-44": its leads are arranged on all four sides of the chip, and it features a higher pin count than SOIC.
    • Features: It can support more functions (more pins correspond to more chip functions), with a size smaller than DIP but larger than BGA.
    • Applicable scenarios: Devices with moderate complexity (such as some feature-rich microcontrollers and small industrial control board chips).
  • BGA package (Ball Grid Array package) Take "BGA-100" for example: its pins are the solder balls on the bottom of the chip (rather than exposed pins), featuring an extremely compact size and a very large number of pins.
    • Features: It can accommodate a large number of pins (supporting high-performance chips) and has an extremely small form factor; however, it requires professional equipment for soldering and is hardly usable for beginners.
    • Application scenarios: High-end small devices (e. g., processors in mobile phones and tablets, high-performance sensor chips).

The core differences between these packages lie in their size, pin configuration, and soldering difficulty: DIP (easy to handle) is commonly used by beginners for experiments, SOIC/QFN is typical for compact end products, while BGA is adopted for high-end miniature devices.

USB Flashing Format (UF2) File

UF2 is a brand-new firmware update file format developed by Microsoft for PXT (also known as Microsoft MakeCode), which is particularly suitable for the firmware upgrade process of microcontrollers and embedded devices via Flash memory.

The core features of the UF2 file lie in its divisibility and easy identifiability. Each UF2 file consists of a series of fixed-size (usually 512-byte) data blocks, which can be read independently by the device. When the device detects consecutive data blocks, it will automatically combine them into a firmware image. This design allows the device to start running the update after receiving part of the file, thus improving the reliability of the update.

In addition, UF2 files have a specific trailing structure to facilitate devices in identifying their file type. This feature enables UF2 files to operate seamlessly across various operating systems such as Windows, Linux or macOS, and be compatible with a wide range of development boards.

It has the following characteristics:

  • Easy to use - Users can upload UF2 files to compatible hardware devices via simple drag-and-drop operations;
  • Cross-platform compatibility - Works with multiple operating systems and is widely used in various microcontrollers and development boards;
  • Robustness - Ensures successful firmware updates even in unstable network environments;
  • Flexibility - Can be easily adapted to different hardware architectures and memory layouts.

XIP —— eXecute In Place

The memory units in a microcontroller can be roughly divided into two categories:

  1. RAM: Variables that need to be rewritten during program execution are all stored in RAM;
  2. ROM: Mainly used to store instruction codes and certain fixed values that cannot be modified after the program runs. For example, all code in. c and. h files, global variables, local variables, constant data defined by the 'const' qualifier, and the code in the startup.asm file are all stored in ROM.

Flash memory, also known as flash, combines the advantages of both ROM and RAM: it not only features the electrically erasable programmable (EEPROM) performance, but also retains data without power supply while enabling fast data readout. In the past, embedded systems consistently used ROM (EPROM) as their storage device; however, in recent years, Flash has fully replaced ROM's position in embedded systems.

During the code execution of a microcontroller unit (MCU), it is usually necessary to read the code from ROM or external flash into a RAM buffer before executing it sequentially. However, many modern NOR QSPI flash memories support the XIP (eXecute In Place) function, under which mode the embedded MCU chip can directly fetch instructions from the NOR QSPI flash for the subsequent decoder and executor to use, without the need to read the code into RAM in advance.Simply put, XIP is a mechanism that enables code to be executed directly in flash memory without being loaded into RAM for execution, which reduces the time required for the kernel to be copied from flash memory to RAM.

When flashing a self-developed application to the Raspberry Pi Pico, the program is first written to the external Flash, and then when the chip starts up, the bootloader in its internal ROM loads and executes the program via XIP/Cache.

The specific meaning of each symbol in its name RP2040 is as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.2 RP2040 Chip Part Number Naming Convention

2.1 Block Diagram of the Chip System

For any chip, the block diagram serves as the core starting point for learning — it acts as the chip's "architecture specification" that helps you build a systematic understanding (rather than a scattered list of functions), which is the universal approach to learning all chips. Through the block diagram, you can first grasp the information from the following general dimensions before diving into specific functions:

The RP2040 features dual M0+ processor cores, DMA, on-chip memory, and peripheral blocks connected via an AHB/APB bus structure:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.3 RP2040 Chip Internal Architecture Block Diagram

We can think of a chip as a "miniature factory", where each module in the diagram corresponds to a distinct "workshop / post": some are responsible for computation, some for data transmission, and others for interfacing with external devices. These posts work in tandem to enable the chip to fulfill tasks such as control and arithmetic operations. Below, we will explain the function of each "post" according to the partitions in the diagram:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.4 RP2040 Chip Internal Architecture Partition Analysis

Brief instructions are as follows:

2.2 Pin Mapping

For chip learning, pin mapping serves as the critical link between "the internal functions of a chip" and "the actual physical hardware" — it is a "wiring guide" that creates a one-to-one correspondence between the functional modules in the chip block diagram (such as GPIO, ADC, UART) and the physical pins on the chip package (i. e., the exposed metal legs of the chip).

The reason why it is necessary to understand the pin mapping is as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.5 RP2040 Chip Pin Mapping and Function Description

Take the pinout diagram of this RP2040 as an example: the left side of the diagram shows the physical pin numbers of the chip, while the right side lists the corresponding functions of each pin (for instance, GPIO029/ADC3 means "physical pin 42 corresponds to the GPIO29 function and also supports ADC3 acquisition"). Only by mastering this can you translate the understanding you gained from the block diagram that "there are GPIO and ADC functions" into actual hardware connections and program development — this is also the necessary step when learning any chip, moving from "architecture awareness" to "practical application".

2.3 Pin Multiplexing Function

Put simply, pin multiplexing means "a single GPIO pin can serve multiple roles" — for instance, one GPIO pin can function as an ordinary switch (controlling the on/off state of an LED), be switched to act as an "SPI interface"(to connect to a sensor), or be configured as a "UART interface"(to connect to a serial port). Just like a smartphone's Type-C port that can charge the device, transfer data, and connect to other peripherals, realizing multiple functions through one single port — this is exactly what "multiplexing" refers to.

Each individual GPIO pin can be connected to an internal peripheral via the GPIO function defined below:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.6 RP2040 GPIO Pin Multiplexed Function Table (0-21)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.7 RP2040 GPIO Pin Multiplexed Function Table (22-29)

This table is the " GPIO 'Function Selection Table'", and its structure and usage are very simple:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.8 RP2040 Pin Multiplexed Function Description Table

The function description table above explains the internal components of the chip corresponding to each "role"(for example, SPIx corresponds to the SPI controller inside the chip, and UARTx corresponds to the UART controller), as well as the purpose of each function.

2.4 Brief Introduction to System Characteristics and Architecture

2.4.1 Bus Interconnection Architecture

The bus interconnection structure is the "data transportation system" inside a chip — it governs how data and instructions are transmitted between various functional modules (cores, memory, peripherals), making it one of the core architectures that impact a chip's operating efficiency. Understanding it clarifies how the chip "avoids data transmission congestion" and the "communication priorities of different modules", which is the key to grasping the chip's performance bottlenecks and resource scheduling logic.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.9 RP2040 Chip Bus Interconnect Block Diagram

This diagram illustrates the "internal communication network" of the RP2040, with the core logic as follows:

2.4.2 Address Mapping

To understand address mapping, we must first clarify its core definition: Address mapping refers to the rules by which a chip assigns unique "numeric addresses" to all its internal resources, including ROM, SRAM, and peripheral registers. It is equivalent to assigning a "house number" to every memory block and functional module inside the chip; modules such as the core and DMA can precisely locate and access the corresponding resource via this "house number", i. e., the address.

The reason why address mapping is required is that the arithmetic/control modules of the chip (such as dual-core processors and DMA) can only locate resources through "addresses": for example, when the core needs to read data from the SRAM or configure the communication parameters of the UART, it must first find the storage area of the SRAM and the control registers of the UART via the corresponding addresses — without address mapping, these modules are just like "rooms without house numbers" and cannot be located or accessed at all. The essence of address mapping is to establish a "unique accessible identifier" for resources, which serves as the basic rule for internal communication within the chip.

And the address mapping works in deep coordination with the aforementioned "SRAM partitioning" — take the SRAM of the RP2040 as an example: As previously mentioned, the SRAM is physically divided into 6 banks (SRAM0 to SRAM5), which is designed to support "parallel access" by multiple modules (for instance, while Core0 is accessing SRAM0, the DMA can access SRAM1 simultaneously);The address mapping table assigns separate address ranges to these 6 banks (for example, SRAM0_BASE is 0x21000000 and SRAM1_BASE is 0x21010000).

As a result, when Core0 accesses addresses starting at "0x21000000", they actually map to the physical SRAM0; when the DMA accesses addresses starting at "0x21010000", they correspond to the physical SRAM1 — address mapping enables different modules to access "distinct physical partitions" via "different house numbers", which not only achieves precise resource positioning but also realizes "parallel access" in coordination with the physical partitions of SRAM, avoiding resource conflicts between modules and improving data access efficiency.

The address mapping of RP2040 is as follows:

RP2040 0x00000000 0x10000000 0x20000000 0x40000000
RP2040 M0 0x50000000 0xd0000000 0xe0000000
RP2040 0x00000000 0x10000000 0x11000000 0x12000000 0x13000000 0x14000000 0x15000000 0x15004000 0x18000000
RP2040 0 3 4 5 0x20000000 0x20040000 SRAM4_BASE SRAM5_BASE 0x20041000
RP2040 0x40000000 0x40004000 0x40008000
RP2040 0x40000000 0x40010000 UART0 UART1 SPI0 SPI1
RP2040 0x50000000 0x50100000 0x50110000 PIO0_BASE 0x50200000 PIO1_BASE 0x50300000 0x50400000

IOPORT Peripherals:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.10 RP2040 Chip Address Map (Full Series)

As can also be seen from the address mapping table in the figure:

2.4.3 Processor Subsystem

The RP2040 processor subsystem consists of two Arm Cortex-M0+ processors — each equipped with its standard internal Arm CPU peripherals as well as external peripherals for GPIO access and inter-core communication.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.11 RP2040 Processor Subsystem Architecture Block Diagram

The diagram above illustrates the "working connection framework" of the RP2040 dual-core processor — it defines the communication modes between the two Cortex-M0+ cores (Core0, Core1), other on-chip modules and external devices, serving as the fundamental supporting structure for dual-core collaborative work. The functions of the core communication interfaces are as follows:

Next, we will introduce these key components one by one.

2.4.3.1 Single-cycle IO block (SIO)

SIO is the "high-speed collaboration toolbox" for the dual-core RP2040 processor — it leverages the IOPORT auxiliary bus of the Cortex-M0+ to achieve "single-cycle (ultra-fast)" operations, and is specifically designed to handle tasks with strict speed and timing requirements such as "high-speed data transfer between dual cores", "contention for shared resources", and "high-speed GPIO control", serving as the core supporting module for efficient dual-core collaboration.

The essence of SIO is a "fast lane module" based on the IOPORT auxiliary bus: IOPORT is a dedicated fast bus port of Cortex-M0+, corresponding to the address range starting from 0xd0000000, which can be accessed with ordinary read and write instructions. Moreover, SIO is not connected to the main system bus and only uses this fast channel — this ensures that all read and write operations of SIO can be completed within 1 cycle, featuring high speed and precise timing.

0x50000000 0xd0000000 Cortex-M0 0xe0000000

The specific structure of SIO is shown as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.12 RP2040 Single-cycle IO (SIO) Module Architecture Block Diagram

SIO performs 32-byte accesses by leveraging the auxiliary bus IOPORT of the Cortex-M0, which is designed to save access time, execute high-speed computing tasks, and also serve as a communication channel between two cores.

IOPORT is an auxiliary bus port on the Cortex-M0+ that enables high-speed 32-bit read and write operations.

Processors access their IOPORTs using standard load and store instructions, targeting the dedicated IOPORT address range from 0xd0000000 to 0xdfffffff. The SIO appears as memory-mapped hardware within the IOPORT space.

SIO has a dedicated bus interface for each processor's IOPORT. Due to its strict timing requirements, SIO is not connected to the main system bus, and can only be accessed by the processor or a debugger via the processor debug port.

Read and write operations of SIO are both completed in one cycle, which consists of the following units:

A Layman’s Explanation of SIO

The core functional units included in SIO all serve the purposes of "dual-core collaboration" and "high-speed operation":

  • Dual-core FIFO: It serves as a "high-speed express box" between the two cores
    • FIFO0 can only be written to by Core0 and read by Core1; FIFO1 can only be written to by Core1 and read by Core0.
    • Its function is to enable the dual-core to transmit data and messages quickly (for example, after Core0 processes the sensor data, it directly writes the data into FIFO0, from which Core1 can read it immediately) without going through the main bus, thus avoiding latency.
  • CPUID: The "Identification Badge" of Dual-Core Processors
    • Core0 reads this register and obtains "0", while Core1 reads it and obtains "1".
    • At startup, the two cores run simultaneously. When Core1 reads its own identifier as "1", it enters sleep mode, while Core0, which reads "0", executes the boot program. Through this "identity identifier", task division during dual-core startup is achieved to avoid conflicts.
  • hardware Mutex lock (spinlock): a "shared resource placeholder" for dual-core systems
    • When two cores need to access the same shared resource (such as the same memory block), use this lock: a "read lock" is equivalent to "occupying the resource", while a "write lock" is equivalent to "releasing the resource".
    • Ensure that only one core can use the shared resource at the same time to avoid data confusion.
  • Hardware Division & Interpolator: The "Fast Calculation Accelerator" for Dual-Core Processors
    • A hardware divider enables division operations to be completed within a single cycle (far faster than software-based computation); an interpolator is a piece of hardware that assists with interpolation operations.
    • Its function is to accelerate specific computing tasks and improve the core computing efficiency.
  • IO Shared Access Control: serves as the "high-speed control port" of GPIO
    • Accessing GPIO registers via SIO is a "single-cycle + atomic operation"(the operation will not be interrupted), which is faster and more precise than controlling GPIOs through the main bus.
    • Suitable for scenarios with strict requirements on GPIO timing (such as fast LED blinking control and high-frequency signal output).
2.4.3.2 Interrupt

Interrupts are the core mechanism of the RP2040 for handling "burst tasks" — for example, when a timer expires, data is received via a serial port, or a sensor triggers a signal, the core cannot wait to "finish the task at hand" before handling these events; at such times, an interrupt will "interrupt" the core's current operation to prioritize the urgent task. Meanwhile, the NVIC (Nested Vectored Interrupt Controller) acts as the "interrupt dispatcher" for each core, responsible for managing interrupt priorities and execution sequences, and its logic will be clearly explained below with reference to the table and relevant rules:

IRQ and Priority

  • IRQ: short for "Interrupt Request", is an "urgent call signal" sent by peripherals (such as timers and UARTs) to the processor core. When a peripheral needs the core to process a task immediately — for example, when a timer expires or data is received via a serial port — it triggers the corresponding IRQ, prompting the core to suspend its current work and prioritize handling this urgent task.
  • Priority: refers to the sorting rule for the urgency of interrupt tasks. A chip may receive multiple IRQs at the same time, and tasks with higher priority will be processed first by the core to prevent urgent tasks from being delayed.

Each core (Core0 and Core1) has an independent NVIC, which acts as a dedicated "interrupt dispatcher" and can receive 32 interrupt signals. However, the RP2040 only uses the first 26 of these (IRQ0 to IRQ25), while the remaining IRQ26 to IRQ31 are reserved (though they can also be forcibly triggered). When a peripheral (such as a timer or UART) triggers an urgent task, it sends a signal to the corresponding IRQ, and the NVIC then schedules the core to process it.

On the RP2040, only the lower 26 IRQ signals are connected to the NVIC, while IRQs 26 to 31 are not tied to any source. By writing to bits 26 to 31 in the NVIC ISPR register, the core can still be forced to enter the corresponding interrupt handler.

The interrupt vector table of the RP2040 is as follows. This table acts as the "task list for IRQs", where each IRQ number corresponds to a specific "source of urgent tasks":

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.13 RP2040 Interrupt Sources and IRQ Mapping Table

For example, IRQ0 corresponds to "the IRQ of Timer 0"(meaning Timer 0 has reached its set time), and IRQ20 corresponds to "the IRQ of UART0"(meaning UART0 has received data). Once the core sees the IRQ number, it can immediately identify which peripheral has sent this "urgent call" and then invoke the corresponding handler.

When multiple IRQs are triggered simultaneously, the core processes them in sequence according to their "urgency level", with priority determined in two layers:

RP2040 NVIC_IPR0-7 Cortex-M0 8 4

Support for nested interrupts in hardware: a low-priority interrupt can be preempted by a high-priority interrupt (or another exception such as a hard fault), and the low-priority interrupt will resume once the high-priority exception is completed. This "cutting in line" mechanism ensures that the most urgent tasks are always responded to first.

2.4.3.3 Event Signals

First, let's clarify the core concepts:

In the RP2040, the event signal serves as the core mechanism for dual-core coordination and low-power sleep, with its logic outlined as follows:

2.4.3.4 Debugging

Before understanding the debugging structure, let's first clarify several core concepts:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.15 RP2040 SWD Serial Wire Debug Architecture Block Diagram

This diagram illustrates the debug communication architecture of the RP2040, which implements the unified control of dual-core by an external debugger plus debug reliability assurance, with the core logic as follows:

2.4.4 Cortex-M0+ Core

The core is the central processing brain of a microcontroller chip, and all program execution, data computation, and task scheduling of the chip are ultimately completed by the core, which directly determines the core capability boundaries of the chip (such as computing speed, power consumption level, and supported functions) and serves as the basis for judging "what scenarios the chip is suitable for"(e. g., low-power devices / complex computing devices) and "what tasks it can perform".

The ARM Cortex-M0+ processor is an ultra-low-power, low-cost microprocessor that supports the ARMv6M instruction set.

What is the ARM Cortex-M series?

This is the "microcontroller-specific core family" launched by ARM, which is divided into multiple models to meet different performance and power consumption requirements:

  • M0/M0+: Entry-level, low power consumption, and low cost (e. g., the M0+ used in RP2040), suitable for simple IO control and low-power devices;
  • M3/M4: mid-to-high-end models, supporting more complex operations (the M4 is equipped with a floating-point unit);
  • M7: High-end, suitable for high-performance scenarios.

The Cortex-M0+ is one of the models with "the lowest entry barrier and the lowest power consumption" in this family, focusing on basic control tasks featuring low cost and low power consumption.

The chip has the following features:

What is a "pipeline"?

Instruction pipelining is a parallelized working mechanism for processors to execute instructions: it splits the execution process of a single instruction into multiple stages, allowing different stages to operate simultaneously to improve instruction execution efficiency. The 2-stage pipeline of Cortex-M0+ splits instructions into two steps: "instruction fetch + pre-decode" and "decode + execute": for example, while the previous instruction is in the "decode + execute" stage, the next instruction is already in the "instruction fetch + pre-decode" stage, which is equivalent to "handling two tasks at the same time", enabling even a simple core to execute instructions efficiently.

Commonly used in the following applications:

The block diagram of the system unit is as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.16 ARM Cortex-M0+ Core System Unit Architecture Block Diagram

It can be seen that for the kernel to operate properly, different modules are required to provide it with fundamental support such as power supply, clock, interrupts and debugging, so as to ensure the stable operation of the kernel.

2.4.5 DMA

The core responsibility of a kernel is "computing and processing tasks". If it is made to manually move data (such as reading data from a sensor and storing it into memory), computing power will be wasted — the kernel cannot handle other tasks while moving data. DMA, by contrast, is a "dedicated data transfer tool" that can efficiently complete bulk transfers, allowing the kernel to handle other tasks or even enter low-power sleep mode, which both improves efficiency and saves power.

The DMA (Direct Memory Access) controller has separate read and write master connections to the bus architecture, and can perform bulk data transfers on behalf of the processor. This allows the processor to freely handle other tasks or enter a low-power sleep state.

A standalone DMA read/write operation can handle a maximum of 32-bit data, features 12 independent channels, and each channel monitors a sequence of bus transmissions.

DMA is typically used for data transmission in the following three scenarios:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.17 RP2040 DMA Controller Architecture Block Diagram

The architecture diagram illustrates the "internal workflow" of DMA, and the functions of each module are as follows:

Next, let's take the "peripheral to memory" transfer (e. g., storing sensor data into memory) as an example:

  1. The kernel writes configurations to the Control/Status Registers via the AHB-lite Slave Interface (for example, the source address is the FIFO address of the sensor, the destination address is the address of the memory array, and the transfer length is 100 bytes);
  2. Address Generator Automatically generates the peripheral address to be read and the memory address to be written, and stores them in the Read Address FIFO and Write Address FIFO respectively;
  3. AHB-lite Read Master Reads data from the peripheral and stores it in the Transfer Data FIFO buffer;
  4. AHB-lite Write Master fetches data from the Transfer Data FIFO and writes it to the target address in memory;

During the entire process, the kernel does not need to participate, and the whole procedure is completed automatically by DMA.

Each channel of the DMA is equipped with a corresponding status register, through which software can program and monitor the progress of data read and write operations for that channel. We can visualize each DMA channel as an independent courier, and the status register is exactly the "task list + work log" of this courier:

The size of data transferred via DMA can be 32 bits, 16 bits or 8 bits. Each channel is configured such that the source transfer size matches the destination transfer size.

DMA channels can be combined with each other. For example, one channel can be configured by another channel to load configuration data from a series of control blocks in memory, and then when reconfiguration is required, the second channel can call the first channel via the CHAIN_TO option:

Meanwhile, DMA can also work in coordination with other peripherals, and data is transmitted directly between peripherals and DMA via DREQ channels. The so-called DREQ is a "signal" sent by the peripheral to the DMA, notifying the DMA that "I am ready to receive/transmit data, and you can start the transfer":

For the correspondence between different peripherals and DREQ channels, you can refer to the DREQ table, which is a list mapping "peripheral functions → DREQ channels", where each DREQ number corresponds to a transmit/receive function of a peripheral:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.18 RP2040 Peripheral DREQ Channel and DMA Mapping Table

Taking the above table as an example, we can see that:

DMA can also be used in conjunction with interrupts: when data read/write of a certain channel in DMA is completed, an interrupt can be triggered to make the program perform corresponding operations (for example, after the data transfer is finished, the kernel will analyze these data).

The RP2040 DMA provides two system IRQs with separate masking and status registers (e. g., INTE0, INTE1). Any combination of channel interrupt requests can be routed to either of the system IRQs:

2.4.6 Memory

Here, we will first clarify several core concepts of "mapping"(which forms the foundation of memory access), before explaining the address mapping tables for memory and SRAM. For the resources inside a chip (including memory, registers, and peripherals) to be accessible, they must first be assigned "house numbers" — this is the very essence of "mapping":

For knowledge related to address mapping, register mapping, remapping and other related concepts, please refer to the following link:

Fundamentals of STM32 Register Version — Memory Mapping:

https://developer.aliyun.com/article/935522

【Experience Sharing】STM32 Getting Started Series - STM32 Peripheral Address Mapping

https://shequ.stmicroelectronics.cn/thread-635602-1-1.html

Microcontroller Memory and Memory Mapping (Local Address, Logical Address, Global Address)

https://blog.csdn.net/u014157109/article/details/120370973

Memory access is entirely based on address mapping. Let’s take a closer look at the memory of the RP2040: the RP2040 has built-in ROM and SRAM, and accesses external Flash via the QSPI interface.

2.4.6.1 ROM

16kB Read-Only Memory (ROM) at address 0x00000000. The content in the ROM is fixed once the chip is manufactured, acting as a "pre-installed toolkit built into the chip", which includes:

  1. Initialize the boot routine
  2. Flash boot sequence
  3. Flash Programming Routine
  4. USB mass storage device supporting UF2
  5. Utility libraries, such as fast floating-point arithmetic

The ROM bootloader can be downloaded at this link: https://github.com/raspberrypi/pico-bootrom

This ROM supports single-cycle read-only bus access and is connected to a dedicated AHB-Lite arbiter, allowing it to be accessed concurrently with other memory devices. Any attempt to write to the ROM has no effect and will not trigger a bus fault.

2.4.6.2 SRAM

The on-chip SRAM totals 264 kB, which is physically divided into six banks, a design that significantly boosts the memory bandwidth for multiple bus masters (i. e., allowing multiple bus masters such as Core0, Core1, and the DMA controller to access different banks simultaneously without resource contention). From the software perspective, this entire memory space can be treated as a single 264 kB continuous region for read and write operations, while access to the physical banks is implemented via address mapping.

There are no restrictions on the content stored in each bank: it can hold applications, data buffers, etc.

The bank can be divided into four 16k×32-bit blocks (each of 64 kB) and two 1k×32-bit blocks (each of 4 kB).

Each SRAM bank can be accessed via a dedicated AHB-Lite arbiter, which means different bus masters can access separate SRAM banks in parallel, allowing up to four 32-bit SRAM accesses (one per master) per system clock cycle.

In the memory mapping, the start address of SRAM is 0x20000000, and the base address of each specific bank is as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.19 RP2040 SRAM bank system address and word address mapping table

We can see that this mapping table contains the following information:

We can see that as the system address increments by 4 (since 32 bits = 4 bytes), it will polling different banks in the order of "Bank0 → Bank1 → Bank2 → Bank3", then return to Bank0 to increment the "word address" — for example:

The advantage of this mapping is that when multiple modules access different system addresses simultaneously, they are actually accessing separate physical banks. For instance, when Core0 accesses 0x20000000 (Bank0) and the DMA accesses 0x20000004 (Bank1), the two operations do not interfere with each other, enabling "parallel access" and significantly boosting the read and write speed of the SRAM.

In addition, there are two small 4kB banks in the SRAM (starting at address 0x20040000) that can be dedicated to the two cores (e. g. for storing stack and frequently executed code) — since these are independent banks, core accesses will not be blocked by other modules, thus ensuring operational efficiency.

In addition to the on-chip SRAM, there are two dedicated RAM blocks available for use in certain scenarios:

A Layman’s Guide to Dedicated RAM Blocks

Simply put, they are "sidekick RAM": they have their own dedicated primary functions in normal operation, and when not in use for those tasks, they can "moonlight" as regular memory, essentially acting as a "backup storage area" within the chip.

  • First, let's clarify the "core functions" of the two dedicated RAMs:
    • Flash XIP cache: As mentioned earlier, Flash is an "external storage" device, which is much slower than on-chip SRAM. The XIP (Execute In Place) function temporarily stores frequently used code and data from Flash in a high-speed RAM (cache) — this way, when the core accesses these contents, it can directly read from the cache without waiting for the slow Flash, which is the core responsibility of a cache.
    • USB data DPRAM : DPRAM stands for "Dual-Port RAM", serves as the dedicated data buffer for the USB module. As its core function, when the USB transmits data, it first stores the data in this RAM, which is then processed by the kernel or DMA.
  • There are two scenarios where memory can be "repurposed as regular RAM on a part-time basis": These two RAM modules are normally occupied by their "primary functions", but when the corresponding features are not in use, they can be utilized as standard memory (the address mapping also assigns them "spare address tags" for this purpose):
    • Disable Flash XIP cache → turn the cache into general RAM: If you do not need the XIP acceleration function of Flash (for example, the entire program is stored in on-chip SRAM), you can disable the XIP cache — this RAM originally dedicated to Flash acceleration will be freed up. Its "reserved base address" is 0x15000000, which you can use to store regular programs and data, equivalent to gaining an extra block of memory.
    • Without using USB → USB DPRAM becomes general 4kB memory: If the project you are working on does not require USB functionality (such as a pure sensor acquisition device), the USB module will be idle — its dedicated DPRAM (4kB) will also be freed up, and the corresponding "reserved memory address" is 0x50100000. This 4kB RAM can then be used as general-purpose memory (for storing small data buffers, temporary variables, etc.).

Simply put, this is a "resource multiplexing" design for chips: the RAM dedicated to specific functions is opened up as general memory when those functions are idle, so that the limited storage resources can be utilized more flexibly.

2.4.6.3 Flash

Here, we first introduce two key concepts:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.20 RP2040 external Flash XIP (execute in place) hardware architecture block diagram

The core of the entire structure is to enable external Flash to be accessed in the same way as internal memory, accelerate the access speed with cache, and meanwhile ensure stable communication:

When the kernel intends to read program instructions from the external Flash:

  1. The kernel sends the address to Decode and Config, and parses out which location of the Flash it corresponds to;
  2. The Mux first checks the Read-only Cache: if the content corresponding to this address exists in the Cache, it is directly returned to the kernel;
  3. If the data is not available in the Cache, the SSI module will read the data from the external Flash via QSPI.
  4. The read-back data is first stored in the Cache (to facilitate subsequent reads) and simultaneously passed to the kernel.
  5. When reading a long continuous sequence of instructions, the data will first be stored in the Streaming FIFO and then transferred to the kernel in batches.

All in all, the external Flash can be accessed via the QSPI interface using execute-in-place (XIP) hardware, which allows the system to address and access the external flash in the same way as accessing internal memory.

2.4.7 BOOT Boot Sequence

The "boot sequence" of a chip is just like the whole process from the "black screen power-off state" to "entering the system and being able to run software" after we turn on a computer — after the RP2040 is powered on (power connected) or reset, it will not directly run the program we wrote, but will first execute the built-in "boot process" of the chip, which is divided into two steps: hardware-level preparation work and software-level boot program execution.The bootrom (boot read-only memory) is the core boot code embedded in the 16kB ROM of the chip — as we mentioned earlier, ROM is the storage pre-programmed into the chip at the factory, and the bootrom acts as the "boot toolkit" within it — and it serves as the core executor of the entire boot process.

The startup process here can be divided into the following two stages:

  1. Hardware controlled: The operations performed by the chip before the bootrom bootloader is executed. The bootrom bootloader is software built into the chip, and this process does not require software participation, belonging to the self-initialization of the chip hardware;
  2. Processor controlled: Execute the bootrom bootloader, which falls under the execution of a software boot program.

bootrom bootloader

The bootrom bootloader is a piece of code smaller than 16KB, which is the first to be executed when the chip is powered on or reset. It consists of:

  • Processor core 0 initial boot sequence.
  • Processor core 1 low power wait and launch protocol.
  • USB MSC class-compliant bootloader with UF2 support for downloading code/data to FLASH or RAM.
  • USB PICOBOOT bootloader interface for advanced management.
  • Routines for programming and manipulating the external flash.
  • Fast floating point library.
  • Fast bit counting / manipulation functions.
  • Fast memory fill / copy functions.

We can compare bootrom to the "first administrator" after a chip is powered on, and every single one of its functions is designed to get the chip to smoothly enter its "working state":

  1. Dual-core startup task division: First, initialize Core 0 to get it running first, and meanwhile put Core 1 into a low-power waiting state (to avoid conflicts caused by simultaneous startup of the two cores); after Core 0 is ready, wake up Core 1 to work collaboratively (corresponding to the first two functions);
  2. Program Download and Management: Provides USB-related bootloader functions — for example, we can use a USB cable to download self-written programs in UF2 format to the chip's Flash or RAM (this is the core method we use to program the RP2040); PICOBOOT, on the other hand, is a more professional management interface for advanced chip configuration;
  3. Flash Operation Support: Provides low-level routines for operating external Flash (such as erasing and writing Flash data). Since user programs are usually stored in external Flash, the bootrom must first implement proper Flash read and write functions before it can load the user program;
  4. Utility Library: Built-in high-speed utility functions such as floating-point arithmetic, bit manipulation, memory copy/fill, etc. These are commonly used basic functions pre-provided by bootrom, which can be directly called by subsequent running user programs to improve efficiency.

2.4.7.1 Hardware-controlled boot sequence
  1. When the chip is powered on, the RUN pin is set: the RUN pin acts as the "power-on switch" of the chip, and "setting" means toggling this switch to the "ON" state to inform the chip that "power has been connected and it is ready to start up";
  2. The on-chip voltage regulator waits for the digital chip power supply (DVDD) to stabilize:
    • A voltage regulator is a "voltage stabilizer" that supplies power to the "digital circuit" inside the chip (similar to the voltage stabilization function of a mobile phone charger); DVDD is the dedicated power supply for digital circuits;
    • This step is to wait for the voltage of DVDD to stabilize at a safe value (e. g., 1.8V), so as to prevent the internal circuit of the chip from being burned out due to fluctuating voltage. It is equivalent to the fact that when a computer boots up, the power supply will wait until the output voltage stabilizes before supplying power to the motherboard.
  3. The power-on finite-state machine has been started. As an automatic circuit in the chip responsible for sequentially completing hardware preparation, it will carry out the following tasks in order:
    1. ROSC (Ring Oscillator) has started up and provides a clock source for the clock generator; clk_sys and clk_ref now operate at a relatively low frequency (typically 6.5 MHz):
      • ROSC is the "initial clock source" of the chip (equivalent to the "clockwork" of an alarm clock), which generates a basic "clock signal"(the "heartbeat rhythm" for the chip to operate) after being started;
      • clk_sys is the "main system clock" of the chip, and clk_ref is the "reference clock". Running at a low frequency (6.5MHz) initially is to make the hardware startup safer and more stable, and the speed will be increased according to subsequent requirements.
    2. The reset controller, XIP in-place execution hardware, memory, bus architecture, and processor subsystem all exit the reset state:
      • These hardware modules are in the "reset state"(equivalent to "sleep lock") when power is off;
      • "Exit reset" means to wake up and unlock these modules, bringing them into a "ready-to-operate state" — for example, the memory is ready to store data, the bus is ready to transmit data, and the processor core is ready to execute programs.
    3. Processor core 0 and core 1 start executing the boot program: After all hardware is ready, the two processor cores are woken up and start executing the bootrom boot program built into the chip, and the hardware-controlled boot process ends here.
2.4.7.2 Processor-controlled boot sequence

The processor-controlled boot sequence is the "task allocation + boot mode selection process" after the bootrom bootloader starts executing. At this point, the hardware is already ready; the bootrom (the "boot manager" in the chip) will first assign tasks to the two cores, then determine "where to load the user program from" — either read the program from external Flash, or enter USB mode to wait for the user to flash the program. The entire process is completed automatically by "judging various hardware signals + executing preset logic".

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.21 RP2040 processor-controlled boot sequence flowchart

The first part is the initial division of labor for the dual cores (on the left side of the flowchart). After both cores (Core0 and Core1) enter the bootrom, they first complete the "responsibility division":

  1. "Which core am I? ": Both cores operate simultaneously, but their identities are distinguished via the previously mentioned "CPUID register":
    • If it is Core1: enter the "Sleep until given entry point" state (i. e., sleep and wait for Core0 to assign tasks to it);
    • If it is Core0: proceed with the subsequent boot logic (Core0 is the "main boot core").
  2. "PoR rescue flag set? ": This is the "fault rescue switch" of the chip: if this flag is enabled, it indicates that a previous startup failure has occurred, and Core0 will perform "Clear flag and halt" to wait for manual troubleshooting.
  3. "Watchdog boot-to-SRAM set? "(Does the watchdog require booting from SRAM?): The watchdog acts as the chip's "fault reset utility": if the watchdog is configured to boot from SRAM, Core0 will "Set SP and jump to entry point" — this is the "emergency boot mode", which is typically used for debugging purposes.
  4. "100us delay (pullup on flash CSn)"(100 microsecond delay, with pull-up resistor added to the CSn pin of Flash):"CSn" refers to the "chip select pin" of the external Flash (equivalent to the "switch" of the Flash); the pull-up resistor keeps this pin at a "high level" initially (by default, the Flash is not selected), so as to reserve sufficient startup time for the Flash.
  5. "Read flash CSn"(Read the CSn pin level of the Flash): Determine "whether there is an external Flash" based on the level of the CSn pin:
    • If it is High (high level): it indicates that the Flash exists, and the "Flash boot" process will be followed (jump to the right side of the flowchart);
    • If it is Low (low level): it indicates that there is no Flash, and the process of "USB boot" will be executed (the subsequent step will enter the USB mode, waiting for the user to burn the program via USB).

The second part is the boot mode selection (on the right side of the flowchart): after Core0 confirms that "Flash is present", it starts attempting to boot from Flash; otherwise, it enters USB mode:

2.4.8 Power Supply System

The power supply system serves as the "energy source" of the RP2040. For the chip to function properly, power must be supplied to different functional modules (such as pins, core logic, USB, and ADC). The RP2040 requires five independent power supplies; however, in most applications, some of these power supplies can be combined and connected to a single power source.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.22 RP2040 power supply pins and power classification diagram

Although the official documentation states that 5 separate power supplies are required, in actual project implementation, there is almost no need to connect all 5: since the chip has a built-in "voltage regulator" that can convert a single 3.3V power supply into the voltages required by other modules, in most scenarios, the chip can operate normally with only one 3.3V power supply connected.

2.4.8.1 Digital IO Power Supply (IOVDD)

IOVDD serves as the power supply for the "external pins (IO ports)" of the chip, and is responsible for "providing a voltage reference" for signals during communication between the pins and external devices such as sensors and display screens. For example, if you are connecting a 3.3V sensor, IOVDD should be connected to 3.3V; if you are connecting a 1.8V device, IOVDD should be connected to 1.8V (the applicable range is 1.8V to 3.3V).

IOVDD should be connected to a 100nF capacitor close to the IOVDD pin of each chip.

2.4.8.2 Digital Core Power Supply (DVDD)

DVDD serves as the power supply for the "internal core logic" of the chip (equivalent to the "heart power supply" of the chip), which is responsible for powering core modules such as the kernel, memory and buses, with a rated voltage of 1.1V.

However, we do not need to connect a separate 1.1V power supply, as the chip integrates an on-chip voltage regulator (VREG_VOUT) that can convert IOVDD (or other 1.8V-3.3V power supplies) into 1.1V DVDD; it only requires externally connecting the output of the regulator to the DVDD pin of the chip.

DVDD can be supplied from an off-chip power supply if required. A 100 nF capacitor should be placed close to the DVDD pin of each chip for DVDD.

2.4.8.3 On-Chip Voltage Regulator Input Power Supply (VREG_VIN)

This is the "input power supply" of the chip's "internal voltage regulator". To step down a higher voltage to the 1.1V level of DVDD, the voltage regulator itself requires a dedicated power supply first, and VREG_VIN serves exactly this purpose. It supports an input voltage range of 1.8V to 3.3V, and VREG_VIN can share the same power supply with IOVDD, which eliminates the need for an additional external power supply.

A 1 μF capacitor shall be connected between VREG_VIN and the ground line of the VREG_VIN pin close to the chip.

2.4.8.4 USB PHY Power Supply (USB_VDD)

This is the power supply for the "USB function module" of the chip, which is responsible for USB communication (such as program flashing and connecting to a computer). It has a rated voltage of 3.3V and can share the same 3.3V power supply with IOVDD.

USB_VDD should be decoupled with a 100nF capacitor placed close to the USB_VDD pin of the chip.

2.4.8.5 ADC Power Supply (ADC_AVDD)

ADC_AVDD serves as the power supply for the on-chip "ADC (Analog-to-Digital Converter)", which is responsible for converting analog signals (such as voltage) from sensors into digital signals, and its supply voltage directly affects conversion accuracy: it can operate at nominal supply voltages ranging from 1.8V to 3.3V, but its performance will be degraded when the supply voltage drops below 2.97V. To reduce the number of external power supplies, ADC_AVDD can share the same power source as the digital IO power supply (IOVDD).

It is safe to supply ADC_AVDD at a voltage higher or lower than IOVDD; for example, powering the ADC at 3.3V for optimal performance while supporting 1.8V signal levels on the digital IOs. However, the voltage of the ADC analog input must not exceed IOVDD, for instance, if the voltage of IOVDD is 1.8V, the voltage of the ADC input shall be limited to 1.8V. A voltage higher than IOVDD will result in leakage current through the ESD protection diode.

2.4.8.6 Power-on/power-off sequence

The power supplies of the RP2040 can be powered on or off in any order.

However, if the ADC power supply (ADC_AVDD) is powered on before the digital core power supply (DVDD) is powered on, or powered off after the digital core power supply (DVDD) is powered off, a small transient current may be generated in the ADC power supply (ADC_AVDD). This will not damage the chip, but can be avoided by turning on DVDD before or simultaneously with ADC_AVDD, and turning off DVDD after or simultaneously with ADC_AVDD.

In the most common power supply scheme, the chip is powered by a single 3.3V power supply. Due to the startup time of the voltage regulator on the chip, DVDD will start shortly after ADC_AVDD.

2.4.8.7 Power Supply Scheme
Power supply scheme nameNumber of suppliesPower supply method for each module (core logic)Applicable scenarios
Single 3.3V supply1IOVDD/USB_VDD/ADC_AVDD connected directly to 3.3V; DVDD powered at 1.1V by the on-chip regulatorMost general applications (most common)
External core supply2 (3.3V + 1.1V)IOVDD etc. connected to 3.3V; DVDD connected directly to an external 1.1V supply (VREG_VIN still needs power)With an external 1.1V regulator / low-power scenarios
Separate supply for USB and ADC2 (1.8V + 3.3V)IOVDD connected to 1.8V; USB_VDD/ADC_AVDD connected separately to 3.3VIO signals are 1.8V, but USB/ADC must work properly
Single 1.8V supply1IOVDD etc. connected to 1.8V; DVDD powered at 1.1V by the on-chip regulatorScenarios that do not need the best USB and ADC performance
1. Single 3.3V power supply

In most applications, the RP2040 will be powered by a single 3.3V power supply. The digital IO (IOVDD), USB PHY (USB_VDD), and ADC (ADC_AVDD) will be directly powered by the 3.3V supply, while the 1.1V digital core power supply (DVDD) will be regulated from the 3.3V supply by the on-chip voltage regulator. Note that the regulator output pin (VREG_VOUT) must be connected to the off-chip DVDD pins.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.23 RP2040 single 3.3V supply scheme diagram
2. External core power supply

The digital core (DVDD) can be directly powered by an external 1.1V power supply instead of the on-chip regulator; if a suitable external regulator is available elsewhere in the system, or for low-power applications where it can replace the inefficient linear on-chip voltage regulator, this approach may be worthwhile.

In this case, the output of the on-chip voltage regulator (VREG_VOUT) should not be connected to DVDD, while power still needs to be supplied to the regulator input (VREG_VIN) to enable the chip's power-on reset and power-loss detection functions. The on-chip voltage regulator will power up immediately once VREG_VIN is available, but it can be turned off under software control as soon as the chip exits reset.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.24 RP2040 external 1.1V core supply scheme diagram
3. Independent power supply for USB and ADC

For applications where the digital IO signal level is lower than 3.3V, separate 3.3V power supplies will be required for the USB PHY and ADC, as the USB PHY fails to meet the specifications when the voltage is below 3.135V, and the performance of the ADC is affected when the voltage is below 2.97V.

In the figure below, the digital IO (IOVDD) is powered by 1.8V, and provides separate 3.3V power supplies for the USB PHY (USB_VDD) and the ADC (ADC_AVDD). The regulator input terminal (VREG_VIN) is connected to the 1.8V power supply, although it can equally be connected to a 3.3V power supply. If the 1.8V power supply is generated by an efficient switching-mode regulator, connecting it to the 1.8V power supply will reduce the overall power consumption.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.25 RP2040 scheme diagram with separate 3.3V supply for USB and ADC
4. Single 1.8V power supply

If the functional USB PHY and optimal ADC performance are not required, the RP2040 can be powered from a single supply voltage lower than 3.3V, with DVDD regulated from the 1.8V supply by the on-chip voltage regulator.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.26 RP2040 single 1.8V supply scheme diagram

2.4.9 Core Power Regulator

Brief Overview of Content

The core power regulator of the RP2040 is equivalent to a "compact power adapter" built into the chip: the core logic of the chip requires a 1.1V power supply, while the power supplies we commonly use are 3.3V or 1.8V. This regulator can automatically convert an external 1.8V~3.3V power supply into the voltage required by the core (the default is 1.1V, which can also be adjusted via software to a value between 0.8V and 1.3V). It also comes with "overload protection", with a maximum output current of 100mA, to prevent the core circuit from malfunctioning due to excessive current.

This regulator has 3 operating states:

  • Normal mode provides conventional power supply and outputs a stable voltage;
  • In shutdown mode, the regulator is completely turned off, and the output directly drops to 0V (however, if the regulator is supplying power to the core, this may cause the chip to restart);
  • High-impedance mode sets the output to a "high-impedance state", which is equivalent to "disconnecting its own power supply", facilitating the switch to an external power source for powering the core (for example, the chip is powered by itself first, and then switched to a more power-efficient external power source later).

The regulator features a "status indicator" labeled "ROK": when the output voltage stabilizes at over 90% of the target value, ROK indicates "normal"(high level); when the voltage is unstable or the mode is being switched, ROK indicates "abnormal". Additionally, note the following during use: a small 1μF capacitor must be connected next to its input and output pins to stabilize the voltage, and in most scenarios, it can share a single power supply with the chip pins, eliminating the need for an additional power connection, which is very convenient.

The RP2040 incorporates an on-chip core power regulator, which takes an external 1.8V to 3.3V supply input and powers the DVDD digital core. In most use cases, the regulator’s input supply will share a single external source with the chip’s digital IO supply IOVDD, simplifying overall power supply requirements. For the chip to start up, the voltage regulator is enabled by default and powers up as soon as the input supply is available. Once the chip comes out of reset, the regulator can be disabled and placed into a high-impedance state.

Its output voltage can also be adjusted under software control, which can be set within the range of 0.8V to 1.3V with a minimum adjustment step of 50mV. The default output voltage after initial power-on or reset is 1.1V, and the desired output voltage can be selected by writing to the VSEL field in the VREG register.

The voltage regulator incorporates a current limiter with a maximum output current of 100 mA to prevent the load current from exceeding the maximum rating. When the current exceeds 100 mA, the output voltage will no longer be regulated and will drop below the set voltage value.

If DVDD is directly powered by an external power supply, the voltage regulator can be used elsewhere.

The common power supply scheme is shown in the following figure:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.27 RP2040 core voltage regulator supply and capacitor configuration diagram

The regulator must place a 1μF capacitor close to its input (VREG_VIN) and output (VREG_VOUT) pins.

2.4.9.1 Power Regulator Operating Mode

The on-chip voltage regulator operates in one of three modes. The mode to be used is selected by writing to the EN and HIZ fields in the VREG register, as shown in the table below. Upon initial power-up or after a reset event, the voltage regulator will be in the Normal Operation mode.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.28 RP2040 voltage regulator operating mode configuration table

The differences among the three operating modes are as follows:

2.4.9.2 Power Regulator Output Status Indication

VREG register contains a single status field, ROK, which indicates whether the output of the voltage regulator is properly regulated.

When power is applied, ROK remains at a low level until the regulator starts up and the output voltage reaches the threshold set by ROK (ROK TH.ASSERT); once the output voltage exceeds the threshold set by ROK (ROK TH.ASSERT), ROK is set and remains at a high level.

ROK TH.ASSERT is typically set to approximately 90% of the output voltage.

Please note that adjusting the output voltage to a higher level will cause ROK to go low until the threshold for the higher ROK setting (ROK TH.ASSERT) is reached.

If the regulator is in high-impedance mode, the voltage of ROK will also drop.

2.4.9.3 Power Regulator Register

The voltage regulator shares a register address space with the chip-level reset subsystem. The registers for these two subsystems are listed here. The VREG registers are part of the voltage regulator subsystem. BOD and CHIP_RESET registers are part of the chip-level reset subsystem.

The shared address space is called vreg_and_chip_reset.

VREG_AND_CHIP_RESET The base address of the register is 0x40064000:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.29 RP2040 VREG_AND_CHIP_RESET register offset table
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.30 RP2040 VREG register bit field description table
RP2040 0x40064004 31 8
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.31 RP2040 BOD register bit field description table
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.32 RP2040 CHIP_RESET register bit field description table

The specific parameters of the voltage regulator are as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.33 RP2040 voltage regulator parameter specification table

These values will vary with the load current and capacitance on VREG_VOUT. The above data are the parameter values obtained under the conditions of EN = 1, load current = 0 mA, and VREG_VIN being increased within 100 μs.

2.4.10 Low Power Mode Adjustment

Here, let us first clarify two basic concepts:

The low-power regulation of the RP2040 reduces these two types of power consumption by "putting unused components into an idle state / powering them off".

The RP2040 provides a range of options for reducing dynamic power consumption:

RP2040

Includes:

All digital logic on the RP2040 resides in a single-core power domain, and the following options are available for reducing static power consumption:

RP2040

Include:

2.4.11 Reset

Reset acts as the "emergency restart button" for a chip: when the chip program freezes, the power supply voltage is unstable, or a reboot is required, the reset operation returns the chip (or some of its components) to its initial state to resume operation. The reset of the RP2040 falls into two scenarios:

2.4.11.1 Chip-Level Reset

When the chip is first powered on, the supply voltage suddenly drops insufficiently (e. g., an unexpected power loss, also known as a "brown-out event"), the RUN pin is manually pulled low (equivalent to pressing the chip's "reset button"), or control is exerted via the debug interface, the "chip-level reset subsystem" will return the entire chip to its initial state.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.34 Chip subsystem reset circuit logic diagram

This subsystem has two "reset signals":

These two signals will be automatically triggered under the conditions of "just powered on, unstable power supply, and RUN pin pulled low". In addition, the rescue debug port can independently trigger rst_n_psm to reset the entire chip, while the rescue debug port itself will not be reset (which means "the rescue port can restart the chip and keep itself working at the same time for subsequent debugging convenience"). After the chip reset is completed, the power-on finite-state machine will take over to continue the startup process.

2.4.11.2 Subsystem Reset

Apart from "full chip reset", the software can also independently control the reset of individual peripheral devices — such as USB controllers, PIO, and peripherals including UART, I2C, SPI, as well as components like PLL and ADC (these devices are not core components of the boot chip, and resetting them will not affect the entire chip).

All these peripherals are in the "reset state"(equivalent to not being activated) by default upon power-on. When a certain peripheral is needed, the software manually releases it from the reset state to get it into operation. For example, if a UART malfunctions, there is no need to restart the entire chip — simply reset the UART, and other devices can continue running. The base address of the registers that control these resets is 0x4000c000.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.35 RP2040 reset and power-up state machine

2.4.12 Power-on finite-state machine

The power-on finite-state machine can be understood as the automatic startup wizard after the chip is powered on / reset. It is a pure hardware automatic program responsible for "waking up" various hardware modules in the chip (such as clock, memory, processor) in a fixed order. Just like when a computer is turned on, the power supply must be started first, then the motherboard, hard disk, graphics card, and finally the CPU. The hardware of the chip must also be started in sequence to avoid problems. The power-on finite-state machine is responsible for this "sequential wake-up" task, which is fully automatic without the intervention of software.

The power-on finite-state machine removes the reset state from various hardware blocks in a specific sequence. Each peripheral in the power-on finite-state machine is controlled by the internal rst_n/reset signal, and generates an internal rst_done active-high reset completion signal. The power-on finite-state machine de-asserts the reset for each peripheral, and after waiting for the peripheral to generate the rst_done signal, it de-asserts the reset for the next peripheral.

When the reset subsystem of the chip confirms that the digital core power supply (DVDD) is stable and RUN is at high level, the power-on finite-state machine itself exits the reset state.

The power-on finite-state machine outputs signals via rst_n_run to trigger the exit of many other blocks. This is typically used in applications that require a restart during initialization but cannot be reset when the power-on finite-state machine restarts (i. e., modules that need to keep running continuously), for example:

These modules will not be reset when the finite-state machine restarts, ensuring that the basic functions keep working properly.

The restart sequence of the finite-state machine upon power-on is as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.36 Chip power-up state machine startup flow block diagram

We can see that its wake-up sequence goes from the "most basic hardware" to the "core components", and the process is as follows:

  1. First, start up the ring oscillator (which provides the most basic initial clock, equivalent to establishing the "heartbeat" first);
  2. Restart crystal oscillator (provides a more accurate clock to replace the basic clock);
  3. Then start up the clock generator (to distribute the clock to each module);
  4. Next comes the reset controller (which manages the reset status of subsequent modules);
  5. then activate the bus architecture (the "channels" for data transmission between individual modules);
  6. Re-awaken ROM/SRAM (the area where programs and data are stored);
  7. Then comes XIP (the access function for external Flash, which enables the chip to read external storage);
  8. Next come the chip-level reset and voltage regulator registers (which manage the configuration of power supply and reset);
  9. finally wake up the processor core (CPU, the "brain" of the chip).

The power-on finite-state machine is a fully automated hardware component. It operates without requiring input from the user. There are register controls available to override and view the state of the power-on finite-state machine. This allows the hardware blocks within the power-on finite-state machine to be reset via software when necessary.

The base address of the PSM register of the power-on finite-state machine is 0x40010000.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.37 RP2040 chip clock system architecture diagram

2.4.13 Clock System

Common Analogy

The clock system in a chip can be analogized to the power supply lines in a household:

  • Clock source: the "main power supply" of the household (such as the power grid or backup generator), which is responsible for providing the basic "clock signal" — the "working rhythm" of the chip, equivalent to the "supply voltage" of electrical appliances;
  • Clock Generator: It acts as a "transformer plus switch" in the circuit, responsible for converting the power from the main supply (the base clock) into the voltage required for different electrical appliances (clocks of varying frequencies), and it can also switch the power supply to a specific appliance on or off independently.
  • Each hardware module (GPIO/ADC/USB, etc.): The "refrigerator, TV, table lamp" at home — each appliance requires a different voltage/power, and by the same token, each module needs a different "clock frequency"(operating rhythm).

Why are so many clocks needed?

If all modules operate at the same clock frequency: for instance, if the RTC (Real-Time Clock), which requires a slow pace, is made to use a high frequency of 125MHz, it will be "so overloaded that it malfunctions"; if the USB, which demands a precise frequency, is made to use a low frequency, it will be "too slow to communicate properly".

The function of a clock tree is to assign a "just-right operating rhythm" to different modules, which not only ensures the normal operation of the modules but also saves power consumption (modules not in use can have their clocks turned off).

The clock system can introduce clocks from different clock sources (such as PLL, internal ring oscillator, USB clock, etc.), and use multiple clock generators to provide the required clocks. The clock system can independently start and stop clocks, and change certain clock frequencies while keeping other clock frequencies at their optimal values.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.38 Chip subsystem reset logic circuit diagram

As can be seen in the image above:

In summary, the clock system of the RP2040 is essentially a "clock tree": it first obtains base clocks from sources such as ring oscillators, crystal oscillators, and PLLs clock sources, then uses multiple clock generators to convert these base clocks into clocks of different frequencies and distribute them to various modules including GPIO, ADC, and USB. It also supports independently starting/stopping the clock of a specific module and adjusting the frequency, which not only meets the timing requirements of different modules but also reduces power consumption.

Some common clock parameters are as follows:

2.4.14 GPIO Interfaces and Peripherals

Layman's Explanation of GPIO

GPIO can be understood as the "external multi-functional socket" of a chip:

  • The chip communicates with external devices (such as LEDs, sensors, and serial port modules) through these pins;
  • A GPIO pin is just like a "universal socket" that can be switched to different functions — for example, serving as a UART port, an SPI interface, or a PWM output — which not only saves the number of pins but also enables flexible adaptation to various devices.

The RP2040 features 36 multi-function general-purpose input/output pins, which are divided into two groups:

RP2040 2.3.1.2 2.6.3 36 GPIO0 GPIO29
RP2040 I2C 3 4.4 4.2 4.3 4.5 4.9

Each GPIO can be directly controlled by software running on the processor or by a number of other functional blocks.

2.4.14.1 Function Selection

The logical structure of an example IO is shown in the following figure:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.40 RP2040 chip GPIO function select logic architecture diagram: modules on the left such as PIO and SPI are selected through a "function selector"; after signal inversion / forcing logic, the signal is either output to the pin or received as pin input, and can also trigger an interrupt.

Each GPIO can be controlled by one of multiple peripherals (meaning each GPIO pin can be switched to different functions), or controlled by the software control registers in the SIO:

The function assigned to each GPIO is selected by writing to the FUNCSEL field in the GPIO's CTRL register. Taking GPIO0_CTRL as an example, the available functions on each IO are shown in the table below:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.41 RP2040 chip GPIO function multiplexing control diagram (0-20)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.42 RP2040 chip GPIO function multiplexing control diagram (21-29)

Each GPIO can select one function at a time. Similarly, each peripheral input (e. g., UART0 RX) can only be selected on one GPIO at a time. If the same peripheral input is connected to multiple GPIOs, the peripheral input will see the logical OR of these GPIO inputs.

The function description of the GPIO bank is as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.43 GPIO bank function diagram

The functions of the QSPI bank of General-Purpose Input/Output (GPIO) are described as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.44 QSPI interface pin function mapping table (SCK, CSn, SD0)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.45 QSPI interface pin function mapping table (SD1, SD2, SD3)

This is the QSPI pin group function option table for the RP2040, which lists the available functions for the 6 pins including QSPI_SCK, QSPI_CSn, and QSPI_SD0 to SD3: each pin defaults to the "XIP" function (used to connect an external Flash to enable direct program execution from Flash), and all of them support the "SIO" function, which can be switched to ordinary GPIO under software control.

The function description of the GPIO QSPI bank is as follows:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.46 GPIO QSPI bank function configuration diagram: "XIP" is a synchronous serial interface connected to external Flash, allowing the chip to execute programs directly from SPI / dual-SPI / Quad-SPI Flash; "SIO" is the function for software-controlled GPIO; when this function is selected, these pins can be controlled through dedicated registers, and the pin state can be read at any time.

The six QSPI Bank GPIO pins are typically used by the XIP peripheral to communicate with external flash devices. However, there are two scenarios where these pins can serve as software-controlled GPIOs:

2.4.14.2 Interrupt

GPIO external interrupts can be configured into the following four types, and the interrupt type can be modified at any time:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.47 GPIO interrupt and pad structure description
2.4.14.2 Pads

Each GPIO is connected to the off-chip world via a "Pads". Pads are the electrical interfaces between the internal logic of the chip and external circuits, which convert signal voltage levels, support higher currents, and provide some protection against electrostatic discharge (ESD) events.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.48 GPIO pad electrical characteristics and structure block diagram

The electrical characteristics of Pads can be adjusted to adapt to external circuits. The following adjustments are available:

The base address of the user bank IO register is 0x40014000:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.49 GPIO register address mapping table (GPIO0 to GPIO14)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.50 GPIO register address mapping table (GPIO15 to GPIO24)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.51 Interrupt controller register mapping table (PROC0 and PROC1 interrupt related)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.52 GPIO register address mapping table (PROC0 and PROC1 interrupt related)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.53 Interrupt controller register mapping table (PROC1 and DORMANT_WAKE interrupt related)

2.4.15 Sysinfo Register

Sysinfo registers can be understood as the "About This Device" information area of a chip: just like the page on a mobile phone where you can check the model and version, they specifically store the basic identity information of the chip. By reading these registers, software can identify which chip it is running on and which version the chip is.

sysinfo module is an area in the chip that stores "basic system information". Its registers start at address 0x40000000 and contain 3 core pieces of information:

sysinfo Registers start at the base address 0x40000000:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.54 Sysinfo register mapping table (chip ID, platform identification, version hash)

2.4.16 Syscfg Register

The Syscfg register can be regarded as the "system-level configuration panel" of the chip — similar to the BIOS settings on a computer, it is specifically used to adjust the parameters of core components such as the processor, debug interface, and memory, so as to adapt the chip to different operation and debugging requirements. All these settings are stored in registers starting at address 0x40004000.

The system configuration block controls various chip settings, including:

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.55 Syscfg register function description list

The system configuration block serves as the "core parameter adjustment zone" of the chip, and it can control these key settings:

The base address of the system configuration register is 0x40004000.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.56 Syscfg register mapping table (low offset address range: NMI mask, processor configuration, GPIO synchronizer bypass)
00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.57 Syscfg register mapping table (low offset address range: NMI mask, processor configuration, GPIO synchronizer bypass)

Corresponding register functions (refer to the table):

2.4.18 TBMAN Test Bench Manager

TBMan (Test Bench Manager) is a "test assistance tool" used in the chip development and simulation phase, which can be likened to the "beta-exclusive debugging function" for software: during the design, simulation and verification stages of a chip, tools are required to control the test environment and check whether functions operate properly, and that is exactly what TBMan is designed for; however, once the chip is actually manufactured, this tool becomes obsolete, leaving only an "identifier" to prove that the chip is a genuine physical product.

The TBMAN registers start at the base address 0x4006c000.

00 Introduction to Raspberry Pi Pico — Draft Document Tutorial
Figure 2.58 TBMAN testbench manager register description

However, on the actually manufactured chips, TBMan serves almost no practical purpose, with only one PLATFORM register (at address 0x4006c000, offset 0x0) retained to indicate "this is a real chip", and this identification function duplicates the platform identifier in the previous Sysinfo register.

3. Introduction to Official Materials

Diagram: 00 Introduction to Raspberry Pi Pico — Draft Document Tutorial

References for this Section

Version Record

Version Number

Modifier

Time

Content

v1.0.0

Li Zisheng

2025/09/16

Initialize the document, based on MicroPython version V1.23.0.

v1.1.0

Li Zisheng

2025/12/05

Add figure caption

v1.2.0

Li Zisheng

2025/12/17

Added plain-language explanations