Datasheet

Table Of Contents
61
62 public start:
63 initial_high: ; Find rising edge at start of bit period
64 wait 1 pin, 0 [11] ; Delay to eye of second half-period (i.e 3/4 of way
65 jmp pin high_0 ; through bit) and branch on RX pin high/low.
66 high_1:
67 in x, 1 ; Second transition detected (a `1` data symbol)
68 jmp initial_high
69 high_0:
70 in y, 1 [1] ; Line still high, no centre transition (data is `0`)
71 ; Fall-through
72
73 .wrap_target
74 initial_low: ; Find falling edge at start of bit period
75 wait 0 pin, 0 [11] ; Delay to eye of second half-period
76 jmp pin low_1
77 low_0:
78 in y, 1 ; Line still low, no centre transition (data is `0`)
79 jmp initial_high
80 low_1: ; Second transition detected (data is `1`)
81 in x, 1 [1]
82 .wrap
This code assumes that X and Y have the values 1 and 0, respectively. This is arranged for by the included C helper
function:
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/pio/differential_manchester/differential_manchester.pio Lines 85 - 101
Ê85 static inline void differential_manchester_rx_program_init(PIO pio, uint sm, uint offset,
Ê uint pin, float div) {
Ê86 pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, false);
Ê87 pio_gpio_select(pio, pin);
Ê88
Ê89 pio_sm_config c = differential_manchester_rx_program_get_default_config(offset);
Ê90 sm_config_set_in_pins(&c, pin); // for WAIT
Ê91 sm_config_set_jmp_pin(&c, pin); // for JMP
Ê92 sm_config_set_in_shift(&c, true, true, 32);
Ê93 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_RX);
Ê94 sm_config_set_clkdiv(&c, div);
Ê95 pio_sm_init(pio, sm, offset, &c);
Ê96
Ê97 // X and Y are set to 0 and 1, to conveniently emit these to ISR/FIFO.
Ê98 pio_sm_exec(pio, sm, pio_encode_set(pio_x, 1));
Ê99 pio_sm_exec(pio, sm, pio_encode_set(pio_y, 0));
100 pio_sm_enable(pio, sm, true);
101 }
All the pieces now exist to loopback some serial data over a wire between two GPIOs.
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/pio/differential_manchester/differential_manchester.c Lines 1 - 43
Ê1 /**
Ê2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
Ê3 *
Ê4 * SPDX-License-Identifier: BSD-3-Clause
Ê5 */
Ê6
Ê7 #include <stdio.h>
Ê8
Ê9 #include "pico/stdlib.h"
RP2040 Datasheet
3.6. Examples 359