RP2040
A microcontroller
by Raspberry Pi
Colophon
© 2020-2025 Raspberry Pi Ltd (formerly Raspberry Pi (Trading) Ltd.)
This documentation is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND).
Portions Copyright © 2019 Synopsys, Inc.
All rights reserved. Used with permission. Synopsys & DesignWare are registered trademarks of Synopsys, Inc.
Portions Copyright © 2000-2001, 2005, 2007, 2009, 2011-2012, 2016 Arm Limited.
All rights reserved. Used with permission.
build-date: 2025-02-20
build-version: 3184e62-clean
Legal disclaimer notice
TECHNICAL AND RELIABILITY DATA FOR RASPBERRY PI PRODUCTS (INCLUDING DATASHEETS) AS MODIFIED FROM TIME TO TIME ("RESOURCES") ARE PROVIDED BY RASPBERRY PI LTD ("RPL") "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW IN NO EVENT SHALL RPL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE RESOURCES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
RPL reserves the right to make any enhancements, improvements, corrections or any other modifications to the RESOURCES or any products described in them at any time and without further notice.
The RESOURCES are intended for skilled users with suitable levels of design knowledge. Users are solely responsible for their selection and use of the RESOURCES and any application of the products described in them. User agrees to indemnify and hold RPL harmless against all liabilities, costs, damages or other losses arising out of their use of the RESOURCES.
RPL grants users permission to use the RESOURCES solely in conjunction with the Raspberry Pi products. All other use of the RESOURCES is prohibited. No licence is granted to any other RPL or other third party intellectual property right.
HIGH RISK ACTIVITIES. Raspberry Pi products are not designed, manufactured or intended for use in hazardous environments requiring fail safe performance, such as in the operation of nuclear facilities, aircraft navigation or communication systems, air traffic control, weapons systems or safety-critical applications (including life support systems and other medical devices), in which the failure of the products could lead directly to death, personal injury or severe physical or environmental damage ("High Risk Activities"). RPL specifically disclaims any express or implied warranty of fitness for High Risk Activities and accepts no liability for use or inclusions of Raspberry Pi products in High Risk Activities.
Raspberry Pi products are provided subject to RPL's Standard Terms . RPL's provision of the RESOURCES does not expand or otherwise modify RPL's Standard Terms including but not limited to the disclaimers and warranties expressed in them.
Table of contents
| Colophon ..... | 1 |
| Legal disclaimer notice ..... | 1 |
| 1. Introduction ..... | 8 |
| 1.1. Why is the chip called RP2040? ..... | 8 |
| 1.2. Summary ..... | 9 |
| 1.3. The Chip ..... | 9 |
| 1.4. Pinout Reference ..... | 10 |
| 1.4.1. Pin Locations ..... | 10 |
| 1.4.2. Pin Descriptions ..... | 11 |
| 1.4.3. GPIO Functions ..... | 12 |
| 2. System Description ..... | 14 |
| 2.1. Bus Fabric ..... | 14 |
| 2.1.1. AHB-Lite Crossbar ..... | 15 |
| 2.1.2. Atomic Register Access ..... | 17 |
| 2.1.3. APB Bridge ..... | 17 |
| 2.1.4. Narrow IO Register Writes ..... | 17 |
| 2.1.5. List of Registers ..... | 18 |
| 2.2. Address Map ..... | 24 |
| 2.2.1. Summary ..... | 24 |
| 2.2.2. Detail ..... | 24 |
| 2.3. Processor subsystem ..... | 26 |
| 2.3.1. SIO ..... | 27 |
| 2.3.2. Interrupts ..... | 60 |
| 2.3.3. Event Signals ..... | 61 |
| 2.3.4. Debug ..... | 61 |
| 2.4. Cortex-M0+ ..... | 62 |
| 2.4.1. Features ..... | 62 |
| 2.4.2. Functional Description ..... | 64 |
| 2.4.3. Programmer's model ..... | 68 |
| 2.4.4. System control ..... | 73 |
| 2.4.5. NVIC ..... | 74 |
| 2.4.6. MPU ..... | 76 |
| 2.4.7. Debug ..... | 76 |
| 2.4.8. List of Registers ..... | 77 |
| 2.5. DMA ..... | 91 |
| 2.5.1. Configuring Channels ..... | 91 |
| 2.5.2. Starting Channels ..... | 93 |
| 2.5.3. Data Request (DREQ) ..... | 95 |
| 2.5.4. Interrupts ..... | 96 |
| 2.5.5. Additional Features ..... | 96 |
| 2.5.6. Example Use Cases ..... | 97 |
| 2.5.7. List of Registers ..... | 101 |
| 2.6. Memory ..... | 120 |
| 2.6.1. ROM ..... | 120 |
| 2.6.2. SRAM ..... | 121 |
| 2.6.3. Flash ..... | 122 |
| 2.7. Boot Sequence ..... | 128 |
| 2.8. Bootrom ..... | 128 |
| 2.8.1. Processor Controlled Boot Sequence ..... | 129 |
| 2.8.2. Launching Code On Processor Core 1 ..... | 131 |
| 2.8.3. Bootrom Contents ..... | 132 |
| 2.8.4. USB Mass Storage Interface ..... | 143 |
| 2.8.5. USB PICOBOT Interface ..... | 144 |
| 2.9. Power Supplies ..... | 150 |
| 2.9.1. Digital IO Supply (IOVDD) ..... | 151 |
| 2.9.2. Digital Core Supply (DVDD) | 151 |
| 2.9.3. On-Chip Voltage Regulator Input Supply (VREG_VIN) | 151 |
| 2.9.4. USB PHY Supply (USB_VDD) | 151 |
| 2.9.5. ADC Supply (ADC_AVDD) | 152 |
| 2.9.6. Power Supply Sequencing | 152 |
| 2.9.7. Power Supply Schemes | 152 |
| 2.10. Core Supply Regulator | 155 |
| 2.10.1. Application Circuit | 155 |
| 2.10.2. Operating Modes | 156 |
| 2.10.3. Output Voltage Select | 157 |
| 2.10.4. Status | 157 |
| 2.10.5. Current Limit | 157 |
| 2.10.6. List of Registers | 157 |
| 2.10.7. Detailed Specifications | 160 |
| 2.11. Power Control | 160 |
| 2.11.1. Top-level Clock Gates | 160 |
| 2.11.2. SLEEP State | 161 |
| 2.11.3. DORMANT State | 161 |
| 2.11.4. Memory Power Down | 161 |
| 2.11.5. Programmer's Model | 162 |
| 2.12. Chip-Level Reset | 163 |
| 2.12.1. Overview | 163 |
| 2.12.2. Power-on Reset | 164 |
| 2.12.3. Brown-out Detection | 165 |
| 2.12.4. Supply Monitor | 167 |
| 2.12.5. External Reset | 167 |
| 2.12.6. Rescue Debug Port Reset | 167 |
| 2.12.7. Source of Last Reset | 168 |
| 2.12.8. List of Registers | 168 |
| 2.13. Power-On State Machine | 168 |
| 2.13.1. Overview | 168 |
| 2.13.2. Power On Sequence | 168 |
| 2.13.3. Register Control | 169 |
| 2.13.4. Interaction with Watchdog | 169 |
| 2.13.5. List of Registers | 169 |
| 2.14. Subsystem Resets | 172 |
| 2.14.1. Overview | 172 |
| 2.14.2. Programmer's Model | 173 |
| 2.14.3. List of Registers | 175 |
| 2.15. Clocks | 178 |
| 2.15.1. Overview | 178 |
| 2.15.2. Clock sources | 179 |
| 2.15.3. Clock Generators | 183 |
| 2.15.4. Frequency Counter | 186 |
| 2.15.5. Resus | 187 |
| 2.15.6. Programmer's Model | 187 |
| 2.15.7. List of Registers | 194 |
| 2.16. Crystal Oscillator (XOSC) | 216 |
| 2.16.1. Overview | 216 |
| 2.16.2. Usage | 217 |
| 2.16.3. Startup Delay | 217 |
| 2.16.4. XOSC Counter | 217 |
| 2.16.5. DORMANT mode | 218 |
| 2.16.6. Programmer's Model | 218 |
| 2.16.7. List of Registers | 219 |
| 2.17. Ring Oscillator (ROSC) | 221 |
| 2.17.1. Overview | 221 |
| 2.17.2. ROSC/XOSC trade-offs | 222 |
| 2.17.3. Modifying the frequency | 222 |
| 2.17.4. ROSC divider | 223 |
| 2.17.5. Random Number Generator | 223 |
| 2.17.6. ROSC Counter | 223 |
| 2.17.7. DORMANT mode | 223 |
| 2.17.8. List of Registers | 224 |
| 2.18. PLL | 228 |
| 2.18.1. Overview | 228 |
| 2.18.2. Calculating PLL parameters | 228 |
| 2.18.3. Configuration | 232 |
| 2.18.4. List of Registers | 234 |
| 2.19. GPIO | 236 |
| 2.19.1. Overview | 236 |
| 2.19.2. Function Select | 237 |
| 2.19.3. Interrupts | 239 |
| 2.19.4. Pads | 240 |
| 2.19.5. Software Examples | 241 |
| 2.19.6. List of Registers | 244 |
| 2.20. Sysinfo | 305 |
| 2.20.1. Overview | 305 |
| 2.20.2. List of Registers | 305 |
| 2.21. Syscfg | 306 |
| 2.21.1. Overview | 306 |
| 2.21.2. List of Registers | 306 |
| 2.22. TBMAN | 309 |
| 2.22.1. List of Registers | 309 |
| 3. PIO | 311 |
| 3.1. Overview | 311 |
| 3.2. Programmer's Model | 312 |
| 3.2.1. PIO Programs | 312 |
| 3.2.2. Control Flow | 313 |
| 3.2.3. Registers | 314 |
| 3.2.4. Stalling | 317 |
| 3.2.5. Pin Mapping | 318 |
| 3.2.6. IRQ Flags | 318 |
| 3.2.7. Interactions Between State Machines | 318 |
| 3.3. PIO Assembler (pioasm) | 319 |
| 3.3.1. Directives | 319 |
| 3.3.2. Values | 320 |
| 3.3.3. Expressions | 320 |
| 3.3.4. Comments | 320 |
| 3.3.5. Labels | 320 |
| 3.3.6. Instructions | 321 |
| 3.3.7. Pseudoinstructions | 321 |
| 3.4. Instruction Set | 321 |
| 3.4.1. Summary | 321 |
| 3.4.2. JMP | 322 |
| 3.4.3. WAIT | 323 |
| 3.4.4. IN | 324 |
| 3.4.5. OUT | 325 |
| 3.4.6. PUSH | 326 |
| 3.4.7. PULL | 327 |
| 3.4.8. MOV | 328 |
| 3.4.9. IRQ | 329 |
| 3.4.10. SET | 330 |
| 3.5. Functional Details | 331 |
| 3.5.1. Side-set | 331 |
| 3.5.2. Program Wrapping | 332 |
| 3.5.3. FIFO Joining | 334 |
| 3.5.4. Autopush and Autopull | 335 |
| 3.5.5. Clock Dividers | 339 |
| 3.5.6. GPIO Mapping | 340 |
| 3.5.7. Forced and EXEC'd Instructions | 342 |
| 3.6. Examples | 344 |
| 3.6.1. Duplex SPI | 344 |
| 3.6.2. WS2812 LEDs | 348 |
| 3.6.3. UART TX | 350 |
| 3.6.4. UART RX | 352 |
| 3.6.5. Manchester Serial TX and RX | 355 |
| 3.6.6. Differential Manchester (BMC) TX and RX | 357 |
| 3.6.7. I2C | 361 |
| 3.6.8. PWM | 364 |
| 3.6.9. Addition | 366 |
| 3.6.10. Further Examples | 367 |
| 3.7. List of Registers | 368 |
| 4. Peripherals | 383 |
| 4.1. USB | 383 |
| 4.1.1. Overview | 383 |
| 4.1.2. Architecture | 384 |
| 4.1.3. Programmer's Model | 394 |
| 4.1.4. List of Registers | 398 |
| References | 417 |
| 4.2. UART | 417 |
| 4.2.1. Overview | 417 |
| 4.2.2. Functional description | 418 |
| 4.2.3. Operation | 420 |
| 4.2.4. UART hardware flow control | 422 |
| 4.2.5. UART DMA Interface | 424 |
| 4.2.6. Interrupts | 425 |
| 4.2.7. Programmer's Model | 427 |
| 4.2.8. List of Registers | 429 |
| 4.3. I2C | 440 |
| 4.3.1. Features | 440 |
| 4.3.2. IP Configuration | 441 |
| 4.3.3. I2C Overview | 441 |
| 4.3.4. I2C Terminology | 443 |
| 4.3.5. I2C Behaviour | 444 |
| 4.3.6. I2C Protocols | 445 |
| 4.3.7. Tx FIFO Management and START, STOP and RESTART Generation | 448 |
| 4.3.8. Multiple Master Arbitration | 450 |
| 4.3.9. Clock Synchronization | 451 |
| 4.3.10. Operation Modes | 452 |
| 4.3.11. Spike Suppression | 457 |
| 4.3.12. Fast Mode Plus Operation | 458 |
| 4.3.13. Bus Clear Feature | 458 |
| 4.3.14. IC_CLK Frequency Configuration | 459 |
| 4.3.15. DMA Controller Interface | 463 |
| 4.3.16. Operation of Interrupt Registers | 464 |
| 4.3.17. List of Registers | 464 |
| 4.4. SPI | 501 |
| 4.4.1. Overview | 502 |
| 4.4.2. Functional Description | 502 |
| 4.4.3. Operation | 505 |
| 4.4.4. List of Registers | 515 |
| 4.5. PWM | 521 |
| 4.5.1. Overview | 521 |
| 4.5.2. Programmer's Model | 522 |
| 4.5.3. List of Registers | 529 |
| 4.6. Timer | 534 |
| 4.6.1. Overview | 534 |
| 4.6.2. Counter | 535 |
| 4.6.3. Alarms | 535 |
| 4.6.4. Programmer's Model | 536 |
| 4.6.5. List of Registers | 539 |
| 4.7. Watchdog | 544 |
| 4.7.1. Overview | 544 |
| 4.7.2. Tick generation | 544 |
| 4.7.3. Watchdog Counter | 545 |
| 4.7.4. Scratch Registers | 545 |
| 4.7.5. Programmer's Model | 545 |
| 4.7.6. List of Registers | 547 |
| 4.8. RTC | 548 |
| 4.8.1. Storage Format | 548 |
| 4.8.2. Leap year | 549 |
| 4.8.3. Interrupts | 549 |
| 4.8.4. Reference clock | 549 |
| 4.8.5. Programmer's Model | 550 |
| 4.8.6. List of Registers | 553 |
| 4.9. ADC and Temperature Sensor | 557 |
| 4.9.1. ADC controller | 558 |
| 4.9.2. SAR ADC | 559 |
| 4.9.3. ADC ENOB | 561 |
| 4.9.4. INL and DNL | 562 |
| 4.9.5. Temperature Sensor | 563 |
| 4.9.6. List of Registers | 564 |
| 4.10. SSI | 567 |
| 4.10.1. Overview | 568 |
| 4.10.2. Features | 568 |
| 4.10.3. IP Modifications | 569 |
| 4.10.4. Clock Ratios | 570 |
| 4.10.5. Transmit and Receive FIFO Buffers | 571 |
| 4.10.6. 32-Bit Frame Size Support | 572 |
| 4.10.7. SSI Interrupts | 572 |
| 4.10.8. Transfer Modes | 573 |
| 4.10.9. Operation Modes | 574 |
| 4.10.10. Partner Connection Interfaces | 579 |
| 4.10.11. DMA Controller Interface | 595 |
| 4.10.12. APB Interface | 597 |
| 4.10.13. List of Registers | 598 |
| 5. Electrical and Mechanical | 607 |
| 5.1. Package | 607 |
| 5.1.1. Thermal characteristics | 608 |
| 5.1.2. Recommended PCB Footprint | 608 |
| 5.1.3. Package markings | 608 |
| 5.2. Storage conditions | 609 |
| 5.3. Solder profile | 609 |
| 5.4. Compliance | 611 |
| 5.5. Pinout | 611 |
| 5.5.1. Pin Locations | 611 |
| 5.5.2. Pin Definitions | 612 |
| 5.5.3. Pin Specifications | 614 |
| 5.6. Power Supplies | 622 |
| 5.7. Power Consumption | 622 |
| 5.7.1. Peripheral power consumption | 622 |
| 5.7.2. Power consumption for typical user cases | 623 |
| Appendix A: Register Field Types | 625 |
| Standard types | 625 |
| RW: | 625 |
| RO: | 625 |
| WO: | 625 |
| Clear types | 625 |
| SC | 625 |
| WC ..... | 625 |
| FIFO types ..... | 626 |
| RWF ..... | 626 |
| RF ..... | 626 |
| WF ..... | 626 |
| Appendix B: Errata ..... | 627 |
| Bootrom ..... | 627 |
| RP2040-E9 ..... | 627 |
| RP2040-E14 ..... | 627 |
| Clocks ..... | 628 |
| RP2040-E7 ..... | 628 |
| RP2040-E10 ..... | 628 |
| DMA ..... | 629 |
| RP2040-E12 ..... | 629 |
| RP2040-E13 ..... | 629 |
| GPIO / ADC ..... | 630 |
| RP2040-E6 ..... | 630 |
| RP2040-E11 ..... | 630 |
| USB ..... | 630 |
| RP2040-E2 ..... | 630 |
| RP2040-E3 ..... | 631 |
| RP2040-E4 ..... | 631 |
| RP2040-E5 ..... | 631 |
| RP2040-E15 ..... | 633 |
| RP2040-E16 ..... | 634 |
| Watchdog ..... | 634 |
| RP2040-E1 ..... | 634 |
| XIP Flash ..... | 635 |
| RP2040-E8 ..... | 635 |
| Appendix C: Availability ..... | 636 |
| Support ..... | 636 |
| Ordering code ..... | 636 |
| Documentation Release History ..... | 637 |
| 20 February 2025 ..... | 637 |
| 15 October 2024 ..... | 637 |
| 02 May 2024 ..... | 637 |
| 02 February 2024 ..... | 637 |
| 14 June 2023 ..... | 637 |
| 03 March 2023 ..... | 637 |
| 01 December 2022 ..... | 637 |
| 30 June 2022 ..... | 638 |
| 17 June 2022 ..... | 638 |
| 04 November 2021 ..... | 638 |
| 03 November 2021 ..... | 638 |
| 30 September 2021 ..... | 638 |
| 23 June 2021 ..... | 638 |
| 07 June 2021 ..... | 639 |
| 13 April 2021 ..... | 639 |
| 07 April 2021 ..... | 639 |
| 05 March 2021 ..... | 639 |
| 23 February 2021 ..... | 639 |
| 01 February 2021 ..... | 639 |
| 26 January 2021 ..... | 639 |
| 21 January 2021 ..... | 640 |