RP2040 emulator for the testing and debugging of PIO programs
Project description
Emulator for the PIO Blocks within the RP2040 Microcontroller (Python Edition)
Introduction
An emulator for the Programmable Input/Output (PIO) blocks that are present within the Raspberry Pi Foundation's RP2040 Microcontroller. It is designed to assist in the analysis of PIO programs and to help you by:
- Enabling unit tests to be written.
- Answering questions such as: How many clock cycles are being consumed?
- Supporting the visualization of GPIO outputs over time.
- Providing alternatives to debugging on real hardware, which can be time consuming.
Quick Start
Below is a slight variation of the example used within the Quick Start Guide.
from pioemu import emulate
program = [0xE029, 0x0041, 0x2080] # Count down from 9 using X register
generator = emulate(program, stop_when=lambda _, state: state.x_register < 0)
for before, after in generator:
print(f"X register: {before.x_register} -> {after.x_register}")
Additional Examples
Some additional examples include:
- Visualisation of square wave program using Jupyter Notebooks within the
examples/
directory.
- Example for the Pimoroni Blinkt! with Unit Test within the
examples/
directory. - pico-pio-examples
Limitations
This software is under development and currently has limitations - the notable ones are:
-
Only supports a sub-set of the available instructions:
- JMP (PIN and !OSRE variants not implemented)
- MOV (some variants and operations not implemented)
- OUT (PC, ISR and EXEC destinations not implemented)
- PULL (IfEmpty not implemented)
- SET
- WAIT (IRQ variant not implemented)
-
No support for OUT, SET or IN pin-sets; all pin numbers are with respect to Pin 0.
-
Pin-sets do not wrap after GPIO 31.
-
No direct support for the concurrent running of multiple PIO programs; a single State Machine is emulated and not an entire PIO block.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for rp2040-pio-emulator-0.26.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b13974ca1de77a32e91617d09746e9d97fe78468b226cb94ea2dde621d31dded |
|
MD5 | 45f33b7b63924a8f3524d86f59483f30 |
|
BLAKE2b-256 | dda7ab7fa7e71eec38a21a5d84ce458777fdd933fac19755cde4810d85fbcdf7 |
Hashes for rp2040_pio_emulator-0.26.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8af5b5510cb6a10a18bfefef982387a31474d4f2153e60224894fc93485c26c2 |
|
MD5 | 7652a1faece5bdb0f89c49db3d319d7e |
|
BLAKE2b-256 | 5c7761661b5e3850b08d1ac5ba7a75b53ec37d0f05d9b6ce8384f3167623621e |