# Raspberry Pi RP2040 - [https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf) > 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-1664710613509.jpeg]] ## Features - Dual [[ARM Cortex-M#Cortex M0]] @ 133Mhz - 264kB SRAM (in six banks) - Up to 16 MB off-chip flash with dedicated QSPI bus - DMA controller - Fully connected AHB crossbar - Interpolator and integer divider peripherals - On-Chip LDO to generate core voltage - 2 PLLs for USB and core clocks - 30 GPIO (4 of which can do ADC) ## Peripherals ![[rp2040-1664711728286.jpeg]] - 30 [[GPIO]]s (4 [[ADC]]s) - 2 [[UART]]s - 2 [[SPI]] controllers - 2 [[I2C]] controllers - 16 PWM channels - [[USB]] 1.1 controller and PHY, with host and device support - 8 [[#PIO State Machines]] - Internal Temperature Sensor The GPIO pios can be configured to support different peripherals, which makes it quite fantastically easy to layout different boards (compared to how hard-wired peripherals used to be on the microcontrollers that I am used to). There is a low-latency, deterministic access from the processors through the Single-cycle IO block (can only be accessed by the processors, not other devices on the system bus). ![[rp2040-1664718275755.jpeg]] ## Bus Fabric ![[rp2040-1664714408425.jpeg]] The chip uses an [AMBA AHB](https://developer.arm.com/documentation/ihi0011/a/AMBA-AHB)-Lite (Advanced Microcontroller Bus Architecture - Advanced High-performance Bus) , and a [AMBA APB](https://developer.arm.com/documentation/ihi0011/a/AMBA-APB) bus (Advanced Microcontroller Bus Architecture - Advanced Peripheral Bus). There are plenty of details of the setup and performance counters in the datasheet, which is very nice if I want to delve a little bit deeper into the topic. ## Dual processor ![[rp2040-1664718182772.jpeg]] The processors have access to: - 32 hardware spinlocks (through the SIO) - 2 FIFOs for interprocessor communication (8 x 32 bits). One can be written by core 0 and read by core 1, and the other vice versa - one integer divider (8 cycles) for each core - two interpolators per core to speed up certain operations - audio - table lookup generation - quantization and [[dithering]] - texture mapping - decompression - linear feedback ### Sleep state > 0. While in a WFE (or WFI) sleep state, the processor can shut off its internal clock gates, consuming much less power. When both processors are sleeping, and the DMA is inactive, RP2040 as a whole can enter a sleep state, disabling clocks on unused infrastructure such as the busfabric, and waking automatically when one of the processors wakes. ## Supported SDKs - [[C]]/[[C++]] - [Raspberry Pi Documentation - The C/C++ SDK](https://www.raspberrypi.com/documentation/microcontrollers/c_sdk.html#sdk-setup) - [https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf) - [https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf](https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf) - [GitHub - raspberrypi/pico-sdk](https://github.com/raspberrypi/pico-sdk) - [GitHub - raspberrypi/pico-examples](https://github.com/raspberrypi/pico-examples) - [[MicroPython]] - [https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf](https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf) - [https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf](https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf) - [Quick reference for the RP2 — MicroPython 1.19.1 documentation](https://docs.micropython.org/en/latest/rp2/quickref.html) - [rp2 — functionality specific to the RP2040 — MicroPython 1.19.1 documentation](https://docs.micropython.org/en/latest/library/rp2.html) - [[Embedded Rust]] / [[Rust]] - [GitHub - rp-rs/rp-hal: A Rust Embedded-HAL for the rp series microcontrollers](https://github.com/rp-rs/rp-hal) ## Bootloader There is a silicon flashed [[USB Mass Storage]] device bootloader with [[UF2]] support. Sourcecode can be found here: - [GitHub - raspberrypi/pico-bootrom](https://github.com/raspberrypi/pico-bootrom) The bootloader also allows for a PICOBOOT access over [[USB]] to interact with the device (code, write/read flash/RAM): - [pico-sdk/picoboot.h at master · raspberrypi/pico-sdk · GitHub](https://github.com/raspberrypi/pico-sdk/blob/master/src/common/boot_picoboot/include/boot/picoboot.h) Boot sequence: ![[rp2040-1664718884481.jpeg]] ## PIO [[State Machine]]s There are 2x4 state machine blocks, which can be used to implement various IO standards: - 8080/6800 parallel bus - [[I2C]] - [[I2S]] - [[SDIO]] - [[UART]] - [[SPI]] - [[VGA]] with a resistor DAC Each PIO state machine is specialized for IO: - determinism and precise timing - close integration with fixed-function hardware Each [[State Machine]] has: - 2x32 bit shift registers - 2x32 bit scratch registers - 4x32 bit FIFO (or one 8x32 in a single direction) - clock divider - flexible GPIO mapping - DMA at 1 word per clock - IRQ set/clear/status ## Rust for RP2040 ### rp-hal - [GitHub - rp-rs/rp-hal: A Rust Embedded-HAL for the rp series microcontrollers](https://github.com/rp-rs/rp-hal) A project template to use, with flip-link, probe-run, defmt: - [GitHub - rp-rs/rp2040-project-template: A basic rp2040-hal project with blinky and rtt logging example code. With this you can quickly get started on a new rp2040 project](https://github.com/rp-rs/rp2040-project-template) Documentation: - [rp2040_hal - Rust](https://docs.rs/rp2040-hal/latest/rp2040_hal/) Project Template: - [GitHub - rp-rs/rp2040-project-template: A basic rp2040-hal project with blinky and rtt logging example code. With this you can quickly get started on a new rp2040 project](https://github.com/rp-rs/rp2040-project-template) ## Links ### Main documentation page > 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. - [Raspberry Pi Documentation - RP2040](https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html) - [https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdf](https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdf)