A feature that sets the Raspberry Pi Foundation RP2040 microcontroller apart from other microcontrollers is "PIO". The RP2040 datasheet says that the "programmable input/output block (PIO) is a versatile hardware interface. It can support a variety of IO standards… PIO is programmable in the same sense as a processor."

In this guide, you'll learn how to write and use PIO programs from CircuitPython. The official datasheet (chapter 3), the book "Get Started with MicroPython on Raspberry Pi Pico" and pico-examples (pio folder) are helpful resources too, but CircuitPython sometimes deviates from the way that PIO is used in other environments like C or MicroPython.

Major differences between pio in CircuitPython compared to standard pioasm

mov operator restrictions

The mov instruction can accept an optional argument, called an operator, to reverse (::) or invert (~) its argument. In adafruit_pioasm, one or more spaces must come between the :: or ~ and the operand. These spaces are not required by the official dialect.

The official dialect allows "!" to mean the same as "~". This is not accepted by adafruit_pioasm.

Expressions are not supported

Standard pioasm supports expressions like [T1 + 1]. In adafruit_pioasm, calculations are not supported. Instead, use string formatting operations to insert the computed value where necessary, e.g., f"""…[{T1+ 1}]…"""

Interrupts are not supported

The IRQ method of sending signals out of a PIO program is not supported in CircuitPython.

Products

Except as otherwise noted, these examples were designed for the Raspberry Pi Pico but can be adapted to the range of boards with the RP2040 microcontroller. The QT Py RP2040 requires the addition of an external LED and current-limiting resistor for the standard LED examples.

Angled shot of black rectangular microcontroller "Feather RP2040"
A new chip means a new Feather, and the Raspberry Pi RP2040 is no exception. When we saw this chip we thought "this chip is going to be awesome when we give it the Feather...
$11.95
In Stock
Video of hand holding an ItsyBitsy PCB. An on-board LED glows rainbow colors.
A new chip means a new ItsyBitsy, and the Raspberry Pi RP2040 is no exception. When we saw this chip we thought "this chip is going to be awesome when we give it the ItsyBitsy...
$9.95
In Stock
Video of hand holding a QT Py PCB in their hand. An LED glows rainbow colors.
What a cutie pie! Or is it... a QT Py? This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new
$9.95
In Stock
Angle shot of Raspberry Pi Pico RP2040
The Raspberry Pi foundation changed single-board computing when they released the Raspberry Pi computer, now they're ready to...
$4.00
In Stock
Top view of Raspberry Pi Pico with two 20-pin male headers.
The Raspberry Pi foundation changed single-board computing when they released the Raspberry Pi computer, now they're...
$5.00
In Stock
Angled shot of MacroPad
Strap yourself in, we're launching in T-minus 10 seconds...Destination? A new Class M planet called MACROPAD! M here, stands for Microcontroller because this 3x4 keyboard...
$34.95
In Stock
Video of a hand playing with a rainbow-glowing keypad.
Strap yourself in, we're launching in T-minus 10 seconds...Destination? A new Class M planet called MACROPAD! M here stands for Microcontroller because this 3x4 keyboard controller...
Out of Stock

This guide was first published on Mar 03, 2021. It was last updated on Mar 18, 2024.

This page (Overview) was last updated on Mar 08, 2024.

Text editor powered by tinymce.