(Image credit: Raspberry Pi)
Microcontrollers have brought about a new era of low-cost development boards that allow developers and makers to create everything from autonomous robots to home automation projects. Some of those chips can be had for $5 or less, but designing an entire computer around those microcontrollers can be difficult. Decisions such as which ISA (Instruction Set Architecture) to utilize and which class of chip IP to use that provides a balance between price, power and performance can be difficult. Then there are R&D and manufacturing questions, such as which engineering team will design the SoC (System on a Chip) and which manufacturer to choose to produce the chip.
"All of these considerations dictate how useful and affordable your final product is," states James Adams, COO and Director of Hardware at Raspberry Pi. "So, when it came to selecting a chip to power our first microcontroller-class product, Raspberry Pi Pico, we knew that we needed to push that price-performance ratio harder than ever before." The result of that push is the RP2040 SoC, which became the heart of the Raspberry Pi Pico
The chip was designed to be used with the Raspberry Pi range of single-board computers and is the first chip in the new Raspberry Pi Pico series released earlier this year. The chip packs a pair of ARM Cortex-M0+ cores, which provides a dual-core system-on-chip (SoC) designed to deliver high performance at low power. Its advanced architecture provides the performance of a powerful microcontroller, with the flexibility of a programmable I/O subsystem, so that developers can create custom peripherals, or integrate with existing ones. With that in mind, the RP2040 is the first microcontroller explicitly designed for the Raspberry Pi Pico, and it opens up a world of possibilities for developers to create all sorts of projects.
The chip is ideal for low-power embedded applications, such as IoT, robotics, wearables, audio, and more. With a wide range of user-friendly development tools, such as the Pico SDK and the Pico C compiler, which makes it easy to get started with the RP2040.
Hardware specifications
(Fig. 1) The RP2040 offers a small but powerful 7 mm × 7 mm package with just two square millimeters of 40 nm silicon. (Image credit: John McMaster via Raspberry Pi)
As mentioned before, the RP2040 features a pair of ARM Cortex M0+ cores (@ 133 MHz), along with a flexible clock and voltage control, up to 8 MB of on-board Flash memory, 264 KB of RAM, and a wide range of connectivity options, including USB, I2C, SPI, and UART. The complete breakdown is as follows:
Processor:
- Dual-Core Arm Cortex-M0+ processor running at up to 133 MHz
Memory:
- Up to 8 MB of on-board Flash memory
Connectivity:
- USB 2.0
- I2C
- SPI
- UART
Power:
- Operating voltage range from 1.8V to 5.5V
- On-board 3.3V and 1.8V regulator
Peripherals:
- 2x programmable I/O (PIO) state machines
- 8x multi-function timer/counters
- Programmable interrupt controller
- On-board temperature sensor
- 5x 12-bit ADC inputs
- 2x 12-bit DAC outputs
- 4x Serial Peripheral Interfaces (SPI)
- 2x I2C interfaces
- 2x UART interfaces
The diagram (Fig. 1) shows the internal SRAM arranged in banks, which can contain code or data that can be accessed via dedicated AHB bus fabric connections, allowing bus masters to access separate bus slaves without being stalled. DMA bus masters are also provided to offload repetitive data transfer tasks from the processors, increasing the chip's efficiency. As with most Raspberry Pi boards, the GPIO pins can be driven directly or via a variety of dedicated logic functions.
Moreover, a dedicated peripheral IP provides fixed functions such as SPI, I2C, UART, and flexibly configurable PIO controllers that can be utilized to provide a wide range of I/O functions. The chip also features a simple USB controller with embedded PHY to provide FS/LS host or device connectivity under software control. Rounding out the hardware specifications are 4x GPIOs that share package pins with ADC inputs. Along with 2x PLLs that provide a USB or ADC fixed 48MHz clock, a flexible system clock with speeds up to 133 MHz and an internal voltage regulator that supplies the core voltage, so the end product only needs to supply the I/O voltage.
Design example
Fig.2 The RP2040 is designed to be integrated into custom PC boards with a minimal amount of circuitry. (Image credit: Raspberry Pi)
The RP2040 is widely known as being the defacto SoC for the latest generation of the Raspberry Pi Pico (complete with Wi-Fi and Bluetooth capabilities) development board. One of the significant advantages of the chip is its ability to be integrated into nearly any custom PCB design (Fig. 2) with a minimal amount of circuitry, as close to plug-and-play as it gets with any SoC or microcontroller.
The example PCB provides a pair of copper layers with all the SMD components placed on the top side only, making it easy to assemble and affordable. The relatively large track width, clearances and hole sizes could make this design easy to manufacture in-house or from a range of PCB suppliers. Don't let the above image fool you with its large, easy-to-solder components, as the RP2040 is a 56-pin, 7×7mm QFN (Quad Flat No-leads) package with a small pitch (0.4mm pin-to-pin spacing). This means only those with exceptional soldering or reflow skills can drop the chip into a PCB.
That said, numerous manufacturers can produce custom boards based on users' designs. Some even offer design consultations, analysis and simulations, debugging and more. Some third-party venues also offer schematics, BoM and software IDEs for those designing custom boards based on completed projects.
RP2040 programmable IOs
The RP2040's programmable IOs (PIOs) are a set of state machines that have their own assembly language to execute simple I/O tasks without the need to access the main processing core. (Image credit: Raspberry Pi)
The RP2040 microcontroller board is equipped with a range of Programmable I/O (PIO) pins, which can interact with a wide range of external devices. The RP2040 features 24 Programmable I/O pins, which can be configured as either general-purpose input/output (GPIO) pins, analog-to-digital converter (ADC) pins, or serial peripheral interface (SPI) pins. These pins can be used to control and interface with a wide range of external devices, such as motors, sensors, relays, displays, and more. Additionally, the RP2040 board also features two dedicated I2C pins, allowing further control and communication with external I2C devices.
The RP2040 is equipped with a pair of PIO blocks with four state machines each. The blocks can simultaneously execute programs to manipulate the GPIOs and transfer new data. Those PIO state machines execute programs from various sources, such as UART, SPI, I2C and user software. Most boards come with hardware support for those digital communications protocols; however if more protocols are needed, then the programmable PIOs on the RP2040 can come into play, taking on the extra throughput.
Software
All of the latest hardware is nothing without software support. To that end, the RP2040 comes with a well-documented software development kit (SDK) for C and C++, covering all the major features and offering a cross-platform toolchain for development on Windows, macOS, and Linux, along with the Raspberry Pi family itself. Of course, it also includes the Raspberry Pi OS (formerly known as Raspbian) operating system, an official programming language, a selection of pre-installed programming tools and libraries, and access to a range of online resources.
The Raspberry Pi Foundation also provides a range of third-party software, including the official Raspberry Pi desktop environment and a range of applications for the Raspberry Pi. Many popular programming languages and frameworks, such as MicroPython, CircuitPython, and Arduino, are also supported. The chip is also compatible with the Raspberry Pi Foundation's Pico C compiler and the Thonny Python IDE for programming in Python.
It should be noted if users plan to use Python to code, it only requires a suitable editor (such as those mentioned above) and MicroPython installed on the development board. But in the case of C/C++, users will require a CMake file that tells the Pico SDK how to turn the C file into a binary application for an RP2040-based microcontroller board.
When it comes to programming those PIOs, nine assembly instructions can be utilized, including JMP, WAIT, IN, OUT, PUSH, PULL, MOV, IRQ, and SET. Additionally, users can program the PIO interfaces with C/C++ or Python language. An explanation of those nine assembly instructions is as follows:
-JMP: Jump instruction can be a conditional or a non-conditional statement, meaning it transfers the flow of execution by changing the instruction pointer register.
-WAIT: This instruction stalls the execution of the code. Each instruction takes one cycle unless it is stalled using the WAIT instructions.
-PULL: This instruction pops 32-bit words from TX FIFO into the output shift register.
-OUT: This instruction shifts data from the output shift register to other destinations, from 1 to 32 bits at a time.
-PUSH: This instruction writes the ISR content to the RX FIFO.
-IN: This instruction shifts 1 to 32 bits at a time into the register.
-IRQ: This sends a hardware signal to the processor that temporarily stops a running program and allows a special program, an interrupt handler, to run instead.
-MOV: This instruction moves data bytes between the two specified operands.
-SET: This instruction set provides a group of commands for a central processing unit (CPU) in machine language.
These will allow users to program the PIOs to connect virtually any add-on boards, peripherals, sensors and more.
Custom PCB project examples
Since its announcement on January 21st, 2021, manufacturers have designed and produced a myriad of RP2040 custom boards that resemble the Raspberry Pi Pico, which uses the same chip. Some have utilized those boards and have incorporated them into various unique projects, while others have designed PCBs around the tiny chip. Below are a few examples of what can be done using the RP2040 SoC.
Pico MacroPad
The Pico macropad is outfitted with a Raspberry Pi Pico and features six programmable switches and a rotary encoder that can be used for any number of applications. (Image credit: Tyron Wakeford via Hackster.io)
Tyron Wakeford's Pico macro pad/keyboard and volume control is an innovative device designed to make gaming and other applications more enjoyable and efficient. The device combines a macro pad, keyboard and volume control, enabling users to quickly and easily access the necessary functions and settings for everything from gaming to video editing. The device has six programmable macro keys that allow users to quickly set up custom macros, hotkeys and volume control to adjust sound levels, video settings, and more. In addition, the device is ergonomically designed to be comfortable and is made with a durable 3D printed enclosure to ensure long-term use.
PicoClock
The clock is designed around the Raspberry Pi Pico and features a 128 x 32 OLED display, an RTC module, a buzzer and a handy battery charging circuit. (Image credit: Sayantan Pal via Hackster.io)
Sayantan Pal's PicoClock is designed around the Raspberry Pi Pico development board and uses a custom PCB that acts like a Shield add-on board to display the time in an easy-to-read format. It boasts five different clock interfaces and features a built-in buzzer and a timer alarm. One side of the Shield packs a DS3231 RTC IC, a Li-ion battery circuit based on the HT4928s power management chip, and a JST header to connect the battery and a buzzer.
On the other side of the PicoClock board resides the 0.91-inch (128 x 32) OLED display and a pair of push buttons to change the clock interfaces and other features, such as a built-in stopwatch. Sayatan also created a 3D printed desk stand for the PicoClock using Fusion 360, which makes it easy to read and frees up valuable desk space.
PicoLight
The PicoLight is a minimalist adjustable light for low-light photography using an RGB LED matrix. (Image credit: Alexandra Covor, Zalmotek, Mihnea Stoica, Constantin Craciun via Hackster.io)
PicoLight is an innovative light for photography that offers superior lighting quality with a minimalist design. It is designed to provide even lighting for showcasing product shots, projects and other applications. It is small and lightweight, making it ideal for photographers on the go, and it has multiple light control options, including dimming and color temperature controls.
The PicoLight is designed around the Raspberry Pi Pico and features a customized PCB outfitted with an array of WS2812B LEDs situated behind an acrylic panel. It's also outfitted with a rotary encoder and a push-button for adjusting color and brightness and includes a Microchip MCP73831 single cell, Li-Ion/Li-Polymer charge management controller for taking shots on the go.
Conclusion
It's not difficult to see why Raspberry Pi's RP2040 chip is popular among engineers and hobbyists. It's manufactured in-house, which reduces costs considerably, and can be implemented in any number of custom PCB designs, making it versatile for any number of projects. It's a significant step forward in developing low-cost, low-power microcontroller boards with PIO programmability, which opens many connection possibilities.
Have a story tip? Message me at: http://twitter.com/Cabe_Atwell