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}")
Documentation
A Tour of pioemu provides a more detailed explanation than the Quick Start Guide offers. In addition, there is a FAQ available that might contain an answer to your question. However, if none of these provides you with the necessary information then please consider creating a new issue - thanks!
Additional Examples
Some additional examples include:
-
Visualisation of square wave program using Jupyter Notebooks within the
examples/
directory. -
TDD example for the Pimoroni Blinkt! within the
examples/
directory.
Supported Instructions
Instruction | Supported | Notes |
---|---|---|
JMP | :heavy_check_mark: | |
WAIT | :heavy_check_mark: :warning: | IRQ variant is not supported |
IN | :heavy_check_mark: | |
OUT | :heavy_check_mark: :construction: | EXEC destination not implemented |
PUSH | :heavy_check_mark: | |
PULL | :heavy_check_mark: | |
MOV | :heavy_check_mark: :construction: | Some variants and operations not implemented |
IRQ | :heavy_multiplication_x: | |
SET | :heavy_check_mark: |
Known Limitations
This software is under development and currently has limitations - the notable ones are:
-
Not all of the available instructions are supported - please refer to the table above.
-
No support for pin-sets associated with OUT, SET or IN; all pin numbers are with respect to GPIO 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.
Thanks To
- aaronjamt for contributing features and fixes.
- Josverl for contributing features.
- winnylourson for contributing a bug fix.
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.82.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 165f0ff84863647128667e1961d10fb3bfb617ca0d15d2f7300e14b524f0d46a |
|
MD5 | 93941157fe01cf248a423b2df8ca3752 |
|
BLAKE2b-256 | 362ecf981c572d1d5de685faafa0c05ed8c9596b568112dabb70ce9f40cbe166 |
Hashes for rp2040_pio_emulator-0.82.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c01932f29afe57822e12b9eaed86343882f4715864e8b304f9b4c7413fdeec82 |
|
MD5 | 0da1a014c503ddee70ca56e7b082b16b |
|
BLAKE2b-256 | dde6fa3751fa414894adc474ab4d5c69289f53b825ac4cbe21894e57bbf80291 |