RP2040
The RP2040 is a 32-bit 133MHz dual-core ARM Cortex-M0+ microcontroller designed by Raspberry Pi Ltd. It was announced on Jan 21st, 2021 as is the first microcontroller designed by Raspberry Pi Ltd, with the intention of being a cheaper, real-time, hardware orientated computing platform to provide alongside the more powerful RaspberryPi. One distinguishing feature of the RP2040 compared to other microcontrollers is the unique Programmable I/O (PIO) subsystem.
The datasheet for the RP2040 can be found at https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf.
The RP2040 is not a family of microcontrollers (as typical with other vendors), it is a single 56pin, 7x7mm QFN component with a 0.4mm pitch.
Features
The RP2040 contains the following2:
- Dual ARM Cortex-M0+ @ 133MHz
- 264kB on-chip SRAM in six independent banks
- Support for up to 16MB of off-chip Flash memory via dedicated QSPI bus
- DMA controller
- Fully-connected AHB crossbar
- Interpolator and integer divider peripherals
- On-chip programmable LDO to generate core voltage
- 2 on-chip PLLs to generate USB and core clocks
- 30 GPIO pins, 4 of which can be used as analogue inputs
- Peripherals
- 2 UARTs
- 2 SPI controllers
- 2 I2C controllers
- 16 PWM channels
- USB 1.1 controller and PHY, with host and device support
- 8 PIO state machines
For needed peripherals that are not listed above, rather than having to bit-bang them, the 8 PIO state machines allow you to create custom hardware logic to perform these tasks.
For complex designs, the relatively small number of GPIO (30, with only four of them being able to be used as analogue inputs) may become a limiting factor, or may necessitate the use of IO expanders. Whilst the clock speed is blistering fast for a Cortex-M0+, this particular architecture does not contain a floating point unit (FPU), meaning float-point arithmetic has to be done in software.
The RP2040 has a large amount (256kB) of on-board RAM, but it does not contain any on-board flash (non-volatile memory). Application code must be provided on external NOR flash memory via a SPI, DSPI or QSPI interface (which is pretty standard thing to do amongst powerful microcontrollers, less-powerful microcontrollers generally contain on-board flash).
Dividing the SRAM into 6 banks, with dedicated AHB buses, allows bus masters to access different banks of memory at the same time (to increase processor performance).
Raspberry Pi Pico SDK
The Raspberry Pi Pico SDK is a collection of C headers, C libraries and a CMake build system for compiling bare metal applications for RP2040-based devices4. It can be used to build applications for the Raspberry Pi Pico, but is generalized to work with all board designs (even though the name suggests otherwise).
The following C code shows how to print Hello, world!
to a UART using the SDK5:
References
Footnotes
-
Raspberry Pi Ltd. RP2040 (product page). Retrieved 2022-06-07, from https://www.raspberrypi.com/products/rp2040/. ↩
-
Raspberry Pi Ltd. RP2040 Datasheet: A microcontroller by Raspberry Pi.. Retrieved 2022-06-07, from https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf. ↩ ↩2
-
Raspberry Pi Ltd. Hardware design with RP2040: Using RP2040 microcontrollers to build boards and products. Retrieved 2022-06-07, from https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdf. ↩
-
Raspberry Pi Ltd. Raspberry Pi Pico SDK. Retrieved 2022-06-07, from https://raspberrypi.github.io/pico-sdk-doxygen/. ↩
-
Raspberry Pi Ltd. Raspberry Pi Pico SDK: UART Example. Retrieved 2022-06-07, from https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__uart.html#uart_example. ↩