Example Scripts Reference

The RP2040 PIO Emulator and client applications are bundled with a set of built-in example scripts. These scripts loosely follow some of the PIO code examples in the RP2040 datasheet, but are adapted to run as Monitor scripts, using the Monitor specific syntax of commands.

In the Monitor application, the set of thesebuilt-in example scripts can be listed with the Monitor command script --list.

APA102

APA102 Mini (apa102-mini)

Monitor script for APA102 Mini example. To be executed on PIO 0, SM 0. pin_din is mapped to GPIO0 in this example. pin_clk is mapped to GPIO1 in this example.

APA102 RGB555 (apa102-rgb555)

Monitor script for AP102 RGB555 example. To be executed on PIO 0, SM 0. output pin is mapped to GPIO0.

Autopush and Autopull

Auto-Push-Pull (auto-push-pull)

Monitor script for auto-push-pull example (see RP2040 datasheet, Sect. 3.5.4. “Autopush and Autopull”). To be executed on PIO 0, SM 0.

Autopull (autopull)

Monitor script for auto pull example (see RP2040 datasheet, Sect. 3.5.4. “Autopush and Autopull”). To be executed on PIO 0, SM 0. Clock (side-set) output is mapped to GPIO 0. Data (OUT) ouput is mapped to GPIO 1.

Manual Pull (manual-pull)

Monitor script for manual pull example (see RP2040 datasheet, Sect. 3.5.4. “Autopush and Autopull”). To be executed on PIO 0, SM 0. Clock (side-set) output is mapped to GPIO 0. Data (OUT) ouput is mapped to GPIO 1.

Pull Example 1 (pull-example1)

Monitor script for pull_example1 (see RP2040 datasheet, Sect. 3.2.3.1. “Output Shift Register (OSR)”). To be executed on PIO 0, SM 0.

Each FIFO entries holds 4 bytes of output data. Each 2nd cycle, the next byte is output on pins GPIO0…GPIO7.

Pull Example 2 (pull-example2)

Monitor script for pull_example2 (see RP2040 datasheet, Sect. 3.2.3.1. “Output Shift Register (OSR)”). To be executed on PIO 0, SM 0.

Each FIFO entries holds 4 bytes of output data. Each 2nd cycle, the next byte is output on pins GPIO0…GPIO7.

Pull Example 3 (pull-example3)

Monitor script for pull_example3 (see RP2040 datasheet, Sect. 3.2.3.1. “Output Shift Register (OSR)”). To be executed on PIO 0, SM 0.

Each FIFO entries holds 4 bytes of output data. Each 2nd cycle, the next byte is output on pins GPIO0…GPIO7.

Pull Example 4 (pull-example4)

Monitor script like pull_example3 (see RP2040 datasheet, Sect. 3.2.3.1. “Output Shift Register (OSR)”), but with an output of 1 byte every system cycle. To be executed on PIO 0, SM 0.

Each FIFO entries holds 4 bytes of output data. Each 2nd cycle, the next byte is output on pins GPIO0…GPIO7.

Somewhat Manual Pull (somewhat-manual-pull)

Monitor script for partial auto pull example (see RP2040 datasheet, Sect. 3.5.4 “Autopush and Autopull”). To be executed on PIO 0, SM 0. Clock (side-set) output is mapped to GPIO 0. Data (OUT) ouput is mapped to GPIO 1.

Differential Manchester (BMC) TX and RX

Differential Manchester RX (bmc-rx)

Monitor script for BMC RX example (see RP2040 datasheet, Sect. 3.6.6. “Differential Manchester (BMC) TX and RX”). To be executed on PIO 0, SM 0.

Differential Manchester TX (bmc-tx)

Monitor script for BMC TX example (see RP2040 datasheet, Sect. 3.6.6. “Differential Manchester (BMC) TX and RX”). To be executed on PIO 0, SM 0.

Manchester Serial TX and RX

Manchester Serial RX (manchester-rx)

Monitor script for Manchester Serial RX example (see RP2040 datasheet, Sect. 3.6.5. “Manchester Serial TX and RX”). To be executed on PIO 0, SM 0.

Manchester Serial TX (manchester-tx)

Monitor script for Manchester Serial TX example (see RP2040 datasheet, Sect. 3.6.5. “Manchester Serial TX and RX”). To be executed on PIO 0, SM 0.

SPI

SPI CPHA0 (spi-cpha0)

Monitor script for SPI CPHA0 example. To be executed on PIO 0, SM 0. SCK is side-set pin. MOSI is OUT pin. MISO is IN pin. MOSI and MISO mapped to same pin, so we get loopback. n_bits = 8 in this example.

SPI CPHA0 with Chip Select (spi-cpha0-cs)

Monitor script for SPI CPHA0 with Chip Select example. To be executed on PIO 0, SM 0. SCK is side-set pin 0. CSn is side-set pin 1 (n=1). MOSI is OUT pin (host-to-device). MISO is IN pin (device-to-host). MOSI and MISO mapped to same pin, so we get loopback. n_bits = 8 in this example.

SPI CPHA1 (spi-cpha1)

Monitor script for SPI CPHA1 example. To be executed on PIO 0, SM 0. SCK is side-set pin. MOSI is OUT pin. MISO is IN pin. MOSI and MISO mapped to same pin, so we get loopback. n_bits = 8 in this example.

SPI CPHA1 with Chip Select (spi-cpha1-cs)

Monitor script for SPI CPHA1 with Chip Select example. To be executed on PIO 0, SM 0. SCK is side-set pin 0. CSn is side-set pin 1 (n=1). MOSI is OUT pin (host-to-device). MISO is IN pin (device-to-host). MOSI and MISO mapped to same pin, so we get loopback. n_bits = 8 in this example.

SPI TX Fast (spi-tx-fast)

Monitor script for SPI TX Fast example, as described in RP2040 datasheet, Sect. 3.5.1. “Side-set”.

To be executed on PIO 0, SM 0. Data output is fed to GPIO 0. Clock output is fed to GPIO 1.

Squarewave

External Wave (ext-wave)

Monitor script for providing an external square wave signal put onto GPIO pad 23, that changes the pin’s status each 3rd clock cycle. This script serves as an example how to automatically set GPIO pads in sync with another script that is executed in parallel. See chapter “Interfacing With External Data” in the RP2040 PIO Emulator documentation for details.

Squarewave (squarewave)

Monitor script for Squarewave example (base version). To be executed on PIO 0, SM 0.

Squarewave Fast (squarewave-fast)

Monitor script for Squarewave example (“fast” version). To be executed on PIO 0, SM 0.

Squarewave Wrap (squarewave-wrap)

Monitor script for Squarewave example (“wrap” version). To be executed on PIO 0, SM 0.

UART

UART RX (uart-rx)

Monitor script for UART RX example (see RP2040 datasheet, Sect. 3.6.4. “UART RX”). To be executed on PIO 0, SM 0.

UART RX Mini (uart-rx-mini)

Monitor script for UART RX Mini example (see RP2040 datasheet, Sect. 3.6.4. “UART RX”). To be executed on PIO 0, SM 0.

UART TX (uart-tx)

Monitor script for UART TX example. To be executed on PIO 0, SM 0. Output is fed to GPIO 0.

WS2812

WS2812 (ws2812)

Monitor script for ws2812 example. To be executed on PIO 0, SM 0. Output is fed to GPIO 0.

WS2812 LED (ws2812-led)

Monitor script for ws2812_led example, as described in RP2040 datasheet, Sect. 3.2.3.4. “Scratch Registers”.

To be executed on PIO 0, SM 0. Output is fed to GPIO 0.

WS2812 Parallel (ws2812-parallel)

Monitor script for ws2812_parallel example. To be executed on PIO 0, SM 0. Output is fed to GPIO 0.

Other

Addition (addition)

Monitor script for addition example (see RP2040 datasheet, Sect. 3.6.9. “Addition”). To be executed on PIO 0, SM 0.

Clocked Input (clocked-input)

Monitor script for Clocked Input example. To be executed on PIO 0, SM 0. Data input pin is mapped to GPIO0. Clock input pin is mapped to GPIO1.

Exec Example (exec-example)

Monitor script for EXEC’d instructions example.

To be executed on PIO 0, SM 0.

Hello PIO (hello)

Monitor script for Hello PIO example. To be executed on PIO 0, SM 0. pin is mapped to GPIO0 in this example.

HUB75 (hub75)

Monitor script for HUB75 example. To be executed on PIO0, SM0 and SM1.

This example consists of two PIO programs that are executed in parallel on two different state machines. The first PIO program is to be executed on SM0 and cares for output pins GPIO6…GPIO10, GPIO12 and GPIO13. The second PIO program is to be executed on SM1 and cares for GPIO0…GPIO5 and GPIO11. In particular:

  • SM1 RGB (rrggbb) out data pins, mapped to GPIO0…GPIO5.
  • SM0 Row Select out pins are A-E, mapped to GPIO6…GPIO10.
  • SM1 side-set pin 0 is clock_pin, mapped to GPIO11.
  • SM0 side-set pin 0 is Latch (aka Strobe), mapped to GPIO12.
  • SM0 side-set pin 1 is OEn, mapped to GPIO13.

I²C (i2c)

Monitor script for I²C example. To be executed on PIO 0, SM 0. pin_sda is fed to GPIO 0. pin_scl is fed to GPIO 1.

Logic Analyser (logic-analyser)

Monitor script for Logic Analyser example. To be executed on PIO 0, SM 0.

PWM (pwm)

Monitor script for PWM example (see RP2040 datasheet, Sect. 3.6.8. “PWM”). To be executed on PIO 0, SM 0.

ST7789 LCD (st7789-lcd)

Monitor script for ST7789 LCD example. To be executed on PIO 0, SM 0. Data on OUT pin, mapped to GPIO0. Clock on side-set pin, mapped to GPIO1.