Skip to main content

RP2040 emulator for the testing and debugging of PIO programs

Project description

Emulator for the PIO Blocks within the RP2040 Microcontroller (Python Edition)

Build Status Coverage PyPI

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:

  1. Visualisation of square wave program using Jupyter Notebooks within the examples/ directory.

  2. TDD example for the Pimoroni Blinkt! within the examples/ directory.

  3. pico-pio-examples

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:

  1. Not all of the available instructions are supported - please refer to the table above.

  2. No support for pin-sets associated with OUT, SET or IN; all pin numbers are with respect to GPIO 0.

  3. Pin-sets do not wrap after GPIO 31.

  4. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rp2040_pio_emulator-0.83.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

rp2040_pio_emulator-0.83.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file rp2040_pio_emulator-0.83.0.tar.gz.

File metadata

  • Download URL: rp2040_pio_emulator-0.83.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.2 Linux/6.1.0-17-amd64

File hashes

Hashes for rp2040_pio_emulator-0.83.0.tar.gz
Algorithm Hash digest
SHA256 3d1a2147aa9c0b17f39b207d6b57b1381abf189aaa5bcdd0f6062da23c4e9b24
MD5 b7124d82a6deecffac0ef94d307fb012
BLAKE2b-256 dce599dd6dd5f296657e1d995bd425acf882c65ed32e384579ee7a3d24f5d60e

See more details on using hashes here.

File details

Details for the file rp2040_pio_emulator-0.83.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rp2040_pio_emulator-0.83.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ec57b3e263fb7584f88d101b7a27e2cceeed55e02b193beeeeb4c59289dc8bc
MD5 ab62624959ec85f0ae69bde47d7e11ec
BLAKE2b-256 cb98756225253600bd524b0ded97ca7d24d9173d6d4755ad4ae2035f25d843cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page