Skip to content

Week 06: MCU Datasheet

RP2040

RP2040

Raspberry Pi RP2040 is the first microcontroller made by Raspberry Pi, introduced in early 2021. It is a low-cost microcontroller built on a modern 40 nm process node, capable of delivering high performance, low dynamic power consumption, and low leakage, making it suitable for extended-duration battery-operated applications. It offers flexible digital interfaces, making it suitable for many applications, from machine learning to agriculture and motor control.

Chip Overview

RP2040 chip overview

Processor Dual ARM Cortex-M0+ @ 133MHz
Memory
  • 264kB of embedded SRAM in 6 banks
  • Support for up to 16MB of off-chip Flash memory via dedicated QSPI bus
Peripherals
  • 2 UARTs
  • 2 SPI controllers
  • 2 I2C controllers
  • 16 PWM channels
  • 4 channel ADC with internal temperature sensor, 500 ksps, 12-bit conversion
  • USB 1.1 controller and PHY, with host and device support
  • 8 PIO state machines

Pinout Reference

RP2040 has 30 GPIO pins, 4 of which can be used as analog inputs. Each individual GPIO pin can be connected to an internal peripheral via the GPIO functions.

RP2040 pinout

Name Description
GPIOx General-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/ADCy General-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.
QSPIx Interface 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_DP USB 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 XOUT Connect 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.
RUN Global 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 SWDIO Access to the internal Serial Wire Debug multi-drop bus. Provides debug access to both processors, and can be used to download code.
TESTEN Factory test mode pin. Tie to GND.
GND Single external ground connection, bonded to a number of internal ground pads on the RP2040 die.
IOVDD Power supply for digital GPIOs, nominal voltage 1.8V to 3.3V
USB_VDD Power supply for internal USB Full Speed PHY, nominal voltage 3.3V
ADC_AVDD Power supply for analogue-to-digital converter, nominal voltage 3.3V
VREG_VIN Power input for the internal core voltage regulator, nominal voltage 1.8V to 3.3V
VREG_VOUT Power output for the internal core voltage regulator, nominal voltage 1.1V, 100mA max current
DVDD Digital core power supply, nominal voltage 1.1V. Can be connected to VREG_VOUT, or to some other board-level power supply.

Source: RP2040 Datasheet

Comparison with ESP32-S3

RP2040 ESP32
Processor Dual-core ARM Cortex-M0+
up to 133 MHz
Dual-core Xtensa LX7
up to 240 MHz
SRAM 264 KB in 6 banks 512 KB
External Flash Support Up to 16 MB Up to 1 GB
SPI 2 4
I²C 2 2
PWM 16 10
ADC 4 (12-bits) 2 (12-bits)
GPIO(total) 30 45
UART 2 3
Operating Voltage 1.8 / 3.3 V 1.8 / 3.3 V
Temperature Sensor ✔️ ✔️
Touch Sensor - ✔️
WIFI - 2.4 GHz Wi-Fi
Bluetooth - BLE 5.0

Both RP2040 and ESP32 are powerful and versatile microcontrollers. They are both priced very affordably, for example, XIAO RP2040 is priced at USD 5.40, while XIAO ESP32-S3 is slightly more expensive at USD 7.49. While on paper ESP32 is the clear winner in most aspects, which one you choose will depend on each individual project’s requirements.

Various benchmarks show that ESP32 performs 1.5-2 times faster than RP2040. However, RP2040 consumes less power and can operate efficiently on lower voltages. For a project that requires wireless communication, ESP32 will be the better choice with its built-in WiFi and Bluetooth. On the other hand, RP2040’s power efficiency makes it a better choice for low-powered battery-powered devices.

Source: