One of the biggest splashes in the electronics industry this year was Raspberry Pi’s unveiling of its first-ever microcontroller. The Raspberry Pi Pico is a $4 microcontroller board built using the RP2040 microcontroller, which includes a dual-Arm Cortex-M0+ processor and an interesting patent-pending programmable I/O peripheral.
This new RP2040 chip is said to be suited for ultra-low-power Internet of Things (IoT) and embedded applications that incorporate endpoint machine learning. The applications of the new SoC can range from standalone toys to networked IoT devices monitoring industrial oil pipelines.
RP2040. Image used courtesy of Raspberry Pi
In the past, we’ve discussed why Raspberry Pi may not be a good choice for commercial products—but how is the new MCU fundamentally distinct from RPi’s traditional single-board computers? And how might it be of use to the practicing engineers?
Key Specifications of the RP2040
Before delving into a deeper discussion on the ramifications of Raspberry Pi’s entry into the MCU market, it may be useful to first establish the key specifications of the SoC.
The system overview of the RP2040 chip. Image used courtesy of Raspberry Pi
The RP2040 features:
- Dual Arm Cortex-M0+ at 133 MHz
- 264 KB of on-chip RAM
- Support for up to 16 MB of off-chip Flash memory via a dedicated QSPI bus
- DMA controller
- Interpolator and integer divider peripherals
- 30 GPIO pins, two of which can be used as analog inputs
- Two UARTs, two SPI controllers, and two I2C controllers
- 16 PWM channels
- USB 1.1 controller and PHY with host and device support
- Eight PIO state machines
For more information, please refer to the RP2040 and the Raspberry Pi Pico datasheets.
Raspberry Pi Ventures from Single-board Computers to MCUs
The new product from Raspberry Pi is a microcontroller-class product rather than a single-board Linux computer. SBCs are fundamentally similar to desktop computers, but with reduced processing and storage capabilities.
Since they are equipped with an operating system (OS), they can be more easily interfaced with a complex device such as a webcam. The OS allows you to easily download and install the applications you need just as you do with a regular computer.
Obstacles of Single-board Computers
However, SBCs have their own limitations. With SBCs, your code is running under a general-purpose OS and it is more challenging to have low-latency control of the general-purpose input/output pins (GPIOs). Besides, operating systems need to perform several different functions in addition to running your main code. This can cause issues for real-time applications.
These limitations of the OS-based systems become a barrier to Raspberry Pi deployment in applications that need to connect to the physical world and monitor sensors. In such applications, reading sensors and driving actuators are needed and low-latency control of the GPIOs is of paramount importance.
Besides, the Raspberry Pi SBCs do not have analog pins. While it is possible to use analog I/O accessories, this will make the design unnecessarily complicated. Due to these limitations and the high power consumption of the SBCs, Raspberry Pi has decided to break into the crowded microcontroller module market.
Raspberry Pi RP2040 on the Pico board. Image used courtesy of Raspberry Pi
Low Power: The Highlight of the New Devices
The Cortex-M0+ processor—the beating heart of the RP2040—is the most energy-efficient Arm processor available. It has low-power modes that make it suited for certain ultra-low-power IoT applications.
Raspberry Pi Pico, the dev board of the RP2040, consumes about 1.3 mA in its sleep mode. This is not comparable with the low-power mode of a Raspberry Pi Zero that burns about 100 mA.
The low power consumption of the new product allows designers to more easily employ it in power-constrained applications. However, it should be noted that as an MCU, the RP2040 consumes much less power than an SBC.
The power consumption of the RP2040 might instead be compared with any other MCU option for a given project.
A Platform for Endpoint AI
A recent trend in some machine learning (ML) applications is implementing pattern recognition models on small endpoint MCUs rather than running them in the cloud on power-hungry computers.
With endpoint AI, data is analyzed locally on the MCU, negating the need to transmit data through crowded internet connections. This offers several advantages such as increased data privacy and security, lower power consumption, and lower latency. Running ML algorithms on small endpoint MCUs, referred to as TinyML, allows developers to detect interesting patterns in the huge amounts of data gathered by the IoT sensors.
The Arm Cortex-M family is an apt candidate for implementing endpoint AI in general. These MCUs are employed ubiquitously because of their low cost and low power consumption. In the case of the RP2040, the Cortex-M0+ cores are clocked at a high rate of 133 MHz that makes it suited for TinyML. The CPU clock rate can make a big difference when it comes to millisecond-level latency measurements.
The processor subsystem in the RP2040 includes two Arm Cortex-M0+ processors. Image used courtesy of Raspberry Pi
The TensorFlow Lite Micro library is already ported to the RP2040. This allows the users to run machine learning (ML) models and perform sensor-based analysis such as voice and image recognition and accelerometer-based gesture recognition.
Designers can use the general-purpose processor of an MCU to control a set of I/O pins and implement a digital communication protocol such as UART and I2C. In these cases, the CPU has to perform simple but repetitive value assignments to the I/O pins. These repetitive tasks can slow down the CPU. Besides, there might be timing issues, especially when using interrupts.
To address these issues, the RP2040 incorporates an interesting patent-pending programmable I/O (PIO) peripheral that can be used to implement different digital communication protocols as well as less common protocols such as the WS2812 LED protocol.
The RP2040 has two PIO units. Each PIO consists of a set of state machines that can be programmed to execute the repetitive I/O tasks required for implementing digital communication protocols.
Diagram of the RP2040 I/O. Image used courtesy of Raspberry Pi
A special assembly language is introduced by the company to program PIO units. Depending on the I/O requirements of your project, a user can turn the PIO unit into a simple, special-purpose processor that implements an arbitrary communication protocol without adding too much burden on the main CPU.
What do you look for in an MCU for endpoint machine learning applications? Share your thoughts in the comments below.
This post was first published on: All About Circuits