Datasheet

Table Of Contents
The example C program in the SDK will transmit Manchester serial data from GPIO2 to GPIO3 at approximately 10 Mbps
(assuming a system clock of 125 MHz).
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/pio/manchester_encoding/manchester_encoding.c Lines 20 - 43
20 int main() {
21 setup_default_uart();
22
23 PIO pio = pio0;
24 uint sm_tx = 0;
25 uint sm_rx = 1;
26
27 uint offset_tx = pio_add_program(pio, &manchester_tx_program);
28 uint offset_rx = pio_add_program(pio, &manchester_rx_program);
29 printf("Transmit program loaded at %d\n", offset_tx);
30 printf("Receive program loaded at %d\n", offset_rx);
31
32 manchester_tx_program_init(pio, sm_tx, offset_tx, pin_tx, 1.f);
33 manchester_rx_program_init(pio, sm_rx, offset_rx, pin_rx, 1.f);
34
35 pio_sm_enable(pio, sm_tx, false);
36 pio_sm_put_blocking(pio, sm_tx, 0);
37 pio_sm_put_blocking(pio, sm_tx, 0x0ff0a55a);
38 pio_sm_put_blocking(pio, sm_tx, 0x12345678);
39 pio_sm_enable(pio, sm_tx, true);
40
41 for (int i = 0; i < 3; ++i)
42 printf("%08x\n", pio_sm_get_blocking(pio, sm_rx));
43 }
3.6.6. Differential Manchester (BMC) TX and RX
Data Idle 0 0 1 1 0 1
Line (starting low)
Line (starting high)
Figure 52. Differential
Manchester serial line
code, also known as
biphase mark code
(BMC). The line
transitions at the start
of every bit period.
The presence of a
transition in the centre
of the bit period
signifies a 1 data bit,
and the absence, a 0
bit. These encoding
rules are the same
whether the line has
an initial high or low
state.
The transmit program is similar to the Manchester example: it repeatedly shifts a bit from the OSR into X (relying on
autopull to refill the OSR in the background), branches, and drives a GPIO up and down based on the value of this bit. The
added complication is that the pattern we drive onto the pin depends not just on the value of the data bit, as with vanilla
Manchester encoding, but also on the state the line was left in at the end of the last bit period. This is illustrated in Figure
52, where the pattern is inverted if the line is initially high. To cope with this, there are two copies of the test-and-drive
code, one for each initial line state, and these are linked together in the correct order by a sequence of jumps.
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/pio/differential_manchester/differential_manchester.pio Lines 7 - 32
Ê7 .program differential_manchester_tx
Ê8 .side_set 1 opt
Ê9
10 ; Transmit one bit every cycles. In each bit period:
11 ; - A '0' is encoded as a transition at the start of the bit period
12 ; - A '1' is encoded as a transition at the start *and* in the middle
13 ;
14 ; Side-set bit 0 must be mapped to the data output pin.
15 ; Autopull must be enabled.
16
17 public start:
18 initial_high:
19 out x, 1 side 1 ; Start of bit period: always assert transition
RP2040 Datasheet
3.6. Examples 357