1. Introduction

Microcontrollers connect the world of software to the world of hardware. They allow developers to write software which interacts with the physical world in the same deterministic, cycle-accurate manner as digital logic. They occupy the bottom left corner of the price/performance space, outselling their more powerful brethren by a factor of ten to one. They are the workhorses that power the digital transformation of our world.

RP2040 is the debut microcontroller from Raspberry Pi. It brings our signature values of high performance, low cost, and ease of use to the microcontroller space.

With a large on-chip memory, symmetric dual-core processor complex, deterministic bus fabric, and rich peripheral set augmented with our unique Programmable I/O (PIO) subsystem, it provides professional users with unrivalled power and flexibility. With detailed documentation, a polished MicroPython port, and a UF2 bootloader in ROM, it has the lowest possible barrier to entry for beginner and hobbyist users.

RP2040 is a stateless device, with support for cached execute-in-place from external QSPI memory. This design decision allows you to choose the appropriate density of non-volatile storage for your application, and to benefit from the low pricing of commodity Flash parts.

RP2040 is manufactured on a modern 40nm process node, delivering high performance, low dynamic power consumption, and low leakage, with a variety of low-power modes to support extended-duration operation on battery power.

Key features:

Whatever your microcontroller application, from machine learning to motor control, from agriculture to audio, RP2040 has the performance, feature set, and support to make your product fly.

1.1. Why is the chip called RP2040?

The post-fix numeral on RP2040 comes from the following,

  1. 1. Number of processor cores (2)
  2. 2. Loosely which type of processor (M0+)
  3. 3. \( \text{floor}(\log_2(\text{RAM} / 16\text{kB})) \)
  4. 4. \( \text{floor}(\log_2(\text{nonvolatile} / 128\text{kB})) \) or 0 if no onboard nonvolatile storage

see Figure 1 .

Figure 1. An explanation for the name of the RP2040 chip.

Diagram explaining the RP2040 chip name. The name 'RP 2 0 4 0' is shown with red underlines under each part. Arrows point from descriptive text to each part: 'Raspberry Pi' points to 'RP', 'Number of cores' points to '2', 'Type of core (e.g. Cortex-M0+)' points to '0', 'floor(log2(RAM / 16kB))' points to '4', and 'floor(log2(nonvolatile / 128kB))' points to the final '0'.

The diagram illustrates the components of the RP2040 chip name. The name is broken down into five parts: 'RP', '2', '0', '4', and '0'. Each part is underlined in red. Arrows point from descriptive text to each part: 'Raspberry Pi' points to 'RP', 'Number of cores' points to '2', 'Type of core (e.g. Cortex-M0+)' points to '0', 'floor(log2(RAM / 16kB))' points to '4', and 'floor(log2(nonvolatile / 128kB))' points to the final '0'.

Diagram explaining the RP2040 chip name. The name 'RP 2 0 4 0' is shown with red underlines under each part. Arrows point from descriptive text to each part: 'Raspberry Pi' points to 'RP', 'Number of cores' points to '2', 'Type of core (e.g. Cortex-M0+)' points to '0', 'floor(log2(RAM / 16kB))' points to '4', and 'floor(log2(nonvolatile / 128kB))' points to the final '0'.

1.2. Summary

RP2040 is a low-cost, high-performance microcontroller device with flexible digital interfaces. Key features:

1.3. The Chip

RP2040 has a dual M0+ processor cores, DMA, internal memory and peripheral blocks connected via AHB/APB bus fabric.

Figure 2. A system overview of the RP2040 chip

Block diagram of the RP2040 chip architecture

A block diagram of the RP2040 chip. The main components are enclosed in a large box labeled RP2040. - **IOs**: On the left, including Crystal, SWD, GPIO [29:0], and QSPI interfaces connecting to external pins. - **Clock generation**: Includes an Internal oscillator and two PLLs. - **Processors**: Two processor cores, Proc0 and Proc1, connected to an Interrupts block and an SIO (Single-cycle IO) block. - **Bus Fabric**: A central hub connecting processors, DMA, and other components. - **DMA**: Direct Memory Access controller connected to the Bus Fabric. - **Peripherals**: A block containing SPI x2, PWM, UART x2, Timer, RTC, I2C x2, ADC & TS, Reset control, Power on state machine, Sysctrl, Sysinfo, and Watchdog. - **PIO**: Programmable IO block containing PIO0 and PIO1. - **Memory**: Includes XIP / Cache, ROM, and four SRAM banks (SRAM0-3) plus two additional SRAM banks (SRAM4-5). - **USB**: A USB controller connected to the Bus Fabric and external pins. - **Core Supply Regulator**: An internal regulator connected to external power pins. Arrows indicate data flow and control paths between these internal blocks and external interfaces.

Block diagram of the RP2040 chip architecture

Code may be executed directly from external memory through a dedicated SPI, DSPI or QSPI interface. A small cache improves performance for typical applications.

Debug is available via the SWD interface.

Internal SRAM can contain code or data. It is addressed as a single 264 kB region, but physically partitioned into 6 banks to allow simultaneous parallel access from different masters.

DMA bus masters are available to offload repetitive data transfer tasks from the processors.

GPIO pins can be driven directly, or from a variety of dedicated logic functions.

Dedicated hardware for fixed functions such as SPI, I2C, UART.

Flexible configurable PIO controllers can be used to provide a wide variety of IO functions.

A USB controller with embedded PHY can be used to provide FS/LS Host or Device connectivity under software control.

Four ADC inputs which are shared with GPIO pins.

Two PLLs to provide a fixed 48MHz clock for USB or ADC, and a flexible system clock up to 133MHz.

An internal Voltage Regulator to supply the core voltage so the end product only needs supply the IO voltage.

1.4. Pinout Reference

This section provides a quick reference for pinout and pin functions. Full details, including electrical specifications and package drawings, can be found in Chapter 5 .

1.4.1. Pin Locations

10

Figure 3. RP2040
Pinout for QFN-56
7×7mm (reduced ePad
size)

Pinout diagram for RP2040 QFN-56 package showing pin numbers 1-28 and functions like GPIO, QSPI, USB, and power pins.

The diagram shows the top view of the RP2040 QFN-56 package. The pins are arranged in a square pattern. The central area is labeled 'GND'. The pins are numbered 1 through 28. The functions for each pin are listed in the diagram. The pins are color-coded: orange for power pins (IOVDD, DVDD, VREG_VIN, ADC_AVDD), green for general-purpose I/O pins (GPIO), blue for QSPI pins (QSPI_SS_N, QSPI_SD1, QSPI_SD2, QSPI_SD0, QSPI_SCLK, QSPI_SD3), purple for USB pins (USB_DP, USB_DM), and red for VREG_VOUT. The pins are arranged as follows:

Pinout diagram for RP2040 QFN-56 package showing pin numbers 1-28 and functions like GPIO, QSPI, USB, and power pins.

1.4.2. Pin Descriptions

Table 1. The function of each pin is briefly described here. Full electrical specifications can be found in Chapter 5 .

NameDescription
GPIOxGeneral-purpose digital input and output. RP2040 can connect one of a number of internal peripherals to each GPIO, or control GPIOs directly from software.
GPIOx/ADCyGeneral-purpose digital input and output, with analogue-to-digital converter function. The RP2040 ADC has an analogue multiplexer which can select any one of these pins, and sample the voltage.
QSPIxInterface to a SPI, Dual-SPI or Quad-SPI flash device, with execute-in-place support. These pins can also be used as software-controlled GPIOs, if they are not required for flash access.
USB_DM and USB_DPUSB controller, supporting Full Speed device and Full/Low Speed host. A 27Ω series termination resistor is required on each pin, but bus pull-ups and pull-downs are provided internally.
XIN and XOUTConnect a crystal to RP2040's crystal oscillator. XIN can also be used as a single-ended CMOS clock input, with XOUT disconnected. The USB bootloader requires a 12MHz crystal or 12MHz clock input. For recommended crystals, see Crystal Oscillator (Section 2.16) .
RUNGlobal asynchronous reset pin. Reset when driven low, run when driven high. If no external reset is required, this pin can be tied directly to IOVDD.
SWCLK and SWDIOAccess to the internal Serial Wire Debug multi-drop bus. Provides debug access to both processors, and can be used to download code.
TESTENFactory test mode pin. Tie to GND.
GNDSingle external ground connection, bonded to a number of internal ground pads on the RP2040 die.
IOVDDPower supply for digital GPIOs, nominal voltage 1.8V to 3.3V
NameDescription
USB_VDDPower supply for internal USB Full Speed PHY, nominal voltage 3.3V
ADC_AVDDPower supply for analogue-to-digital converter, nominal voltage 3.3V
VREG_VINPower input for the internal core voltage regulator, nominal voltage 1.8V to 3.3V
VREG_VOUTPower output for the internal core voltage regulator, nominal voltage 1.1V, 100mA max current
DVDDDigital core power supply, nominal voltage 1.1V. Can be connected to VREG_VOUT, or to some other board-level power supply.

1.4.3. GPIO Functions

Each individual GPIO pin can be connected to an internal peripheral via the GPIO functions defined below. Some internal peripheral connections appear in multiple places to allow some system level flexibility. SIO, PIO0 and PIO1 can connect to all GPIO pins and are controlled by software (or software controlled state machines) so can be used to implement many functions.

Table 2. General Purpose Input/Output (GPIO) Bank 0 Functions

Function
GPIOF1F2F3F4F5F6F7F8F9
0SPIO RXUART0 TXI2C0 SDAPWM0 ASIOPIO0PIO1USB OVCUR DET
1SPIO CSnUART0 RXI2C0 SCLPWM0 BSIOPIO0PIO1USB VBUS DET
2SPIO SCKUART0 CTSI2C1 SDAPWM1 ASIOPIO0PIO1USB VBUS EN
3SPIO TXUART0 RTSI2C1 SCLPWM1 BSIOPIO0PIO1USB OVCUR DET
4SPIO RXUART1 TXI2C0 SDAPWM2 ASIOPIO0PIO1USB VBUS DET
5SPIO CSnUART1 RXI2C0 SCLPWM2 BSIOPIO0PIO1USB VBUS EN
6SPIO SCKUART1 CTSI2C1 SDAPWM3 ASIOPIO0PIO1USB OVCUR DET
7SPIO TXUART1 RTSI2C1 SCLPWM3 BSIOPIO0PIO1USB VBUS DET
8SPI1 RXUART1 TXI2C0 SDAPWM4 ASIOPIO0PIO1USB VBUS EN
9SPI1 CSnUART1 RXI2C0 SCLPWM4 BSIOPIO0PIO1USB OVCUR DET
10SPI1 SCKUART1 CTSI2C1 SDAPWM5 ASIOPIO0PIO1USB VBUS DET
11SPI1 TXUART1 RTSI2C1 SCLPWM5 BSIOPIO0PIO1USB VBUS EN
12SPI1 RXUART0 TXI2C0 SDAPWM6 ASIOPIO0PIO1USB OVCUR DET
13SPI1 CSnUART0 RXI2C0 SCLPWM6 BSIOPIO0PIO1USB VBUS DET
14SPI1 SCKUART0 CTSI2C1 SDAPWM7 ASIOPIO0PIO1USB VBUS EN
15SPI1 TXUART0 RTSI2C1 SCLPWM7 BSIOPIO0PIO1USB OVCUR DET
16SPIO RXUART0 TXI2C0 SDAPWM0 ASIOPIO0PIO1USB VBUS DET
17SPIO CSnUART0 RXI2C0 SCLPWM0 BSIOPIO0PIO1USB VBUS EN
18SPIO SCKUART0 CTSI2C1 SDAPWM1 ASIOPIO0PIO1USB OVCUR DET
19SPIO TXUART0 RTSI2C1 SCLPWM1 BSIOPIO0PIO1USB VBUS DET
20SPIO RXUART1 TXI2C0 SDAPWM2 ASIOPIO0PIO1CLOCK GPIN0USB VBUS EN
21SPIO CSnUART1 RXI2C0 SCLPWM2 BSIOPIO0PIO1CLOCK GPOUT0USB OVCUR DET
Function
22SPI0 SCKUART1 CTSI2C1 SDAPWM3 ASIOPIO0PIO1CLOCK GPIN1USB VBUS DET
23SPI0 TXUART1 RTSI2C1 SCLPWM3 BSIOPIO0PIO1CLOCK GPOUT1USB VBUS EN
24SPI1 RXUART1 TXI2C0 SDAPWM4 ASIOPIO0PIO1CLOCK GPOUT2USB OVCUR DET
25SPI1 CSnUART1 RXI2C0 SCLPWM4 BSIOPIO0PIO1CLOCK GPOUT3USB VBUS DET
26SPI1 SCKUART1 CTSI2C1 SDAPWM5 ASIOPIO0PIO1USB VBUS EN
27SPI1 TXUART1 RTSI2C1 SCLPWM5 BSIOPIO0PIO1USB OVCUR DET
28SPI1 RXUART0 TXI2C0 SDAPWM6 ASIOPIO0PIO1USB VBUS DET
29SPI1 CSnUART0 RXI2C0 SCLPWM6 BSIOPIO0PIO1USB VBUS EN

Table 3. GPIO bank 0 function descriptions

Function NameDescription
SPIxConnect one of the internal PL022 SPI peripherals to GPIO
UARTxConnect one of the internal PL011 UART peripherals to GPIO
I2CxConnect one of the internal DW I2C peripherals to GPIO
PWMx A/BConnect a PWM slice to GPIO. There are eight PWM slices, each with two output channels (A/B). The B pin can also be used as an input, for frequency and duty cycle measurement.
SIOSoftware control of GPIO, from the single-cycle IO (SIO) block. The SIO function (F5) must be selected for the processors to drive a GPIO, but the input is always connected, so software can check the state of GPIOs at any time.
PIOxConnect one of the programmable IO blocks (PIO) to GPIO. PIO can implement a wide variety of interfaces, and has its own internal pin mapping hardware, allowing flexible placement of digital interfaces on bank 0 GPIOs. The PIO function (F6, F7) must be selected for PIO to drive a GPIO, but the input is always connected, so the PIOs can always see the state of all pins.
CLOCK GPINxGeneral purpose clock inputs. Can be routed to a number of internal clock domains on RP2040, e.g. to provide a 1Hz clock for the RTC, or can be connected to an internal frequency counter.
CLOCK GPOUTxGeneral purpose clock outputs. Can drive a number of internal clocks (including PLL outputs) onto GPIOs, with optional integer divide.
USB OVCUR DET/VBUS DET/VBUS ENUSB power control signals to/from the internal USB controller