Skip to content

Commit 4f64f3a

Browse files
tommessickWren6991
authored andcommitted
Prevent extra bit transition at end of data
The initial bit transition would be set even if the queue stalled. The state machine still takes 16 cycles per bit The next bit starts on state 1 and 9 instead of 0 and 8 so the timing is the same as before
1 parent 612469d commit 4f64f3a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pio/differential_manchester/differential_manchester.pio

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.program differential_manchester_tx
88
.side_set 1 opt
99

10-
; Transmit one bit every cycles. In each bit period:
10+
; Transmit one bit every 16 cycles. In each bit period:
1111
; - A '0' is encoded as a transition at the start of the bit period
1212
; - A '1' is encoded as a transition at the start *and* in the middle
1313
;
@@ -16,19 +16,21 @@
1616

1717
public start:
1818
initial_high:
19-
out x, 1 side 1 ; Start of bit period: always assert transition
20-
jmp !x high_0 [6] ; Test the data bit we just shifted out of OSR
19+
out x, 1 ; Start of bit period: always assert transition
20+
jmp !x high_0 side 1 [6] ; Test the data bit we just shifted out of OSR
2121
high_1:
22-
jmp initial_high side 0 [7] ; For `1` bits, also transition in the middle
22+
nop
23+
jmp initial_high side 0 [6] ; For `1` bits, also transition in the middle
2324
high_0:
2425
jmp initial_low [7] ; Otherwise, the line is stable in the middle
2526

2627
initial_low:
27-
out x, 1 side 0 ; Always shift 1 bit from OSR to X so we can
28-
jmp !x low_0 [6] ; branch on it. Autopull refills OSR for us.
28+
out x, 1 ; Always shift 1 bit from OSR to X so we can
29+
jmp !x low_0 side 0 [6] ; branch on it. Autopull refills OSR for us.
2930
low_1:
30-
jmp initial_low side 1 [7] ; If there are two transitions, return to
31-
low_0: ; initial_low on the next bit. If just one,
31+
nop
32+
jmp initial_low side 1 [6] ; If there are two transitions, return to
33+
low_0:
3234
jmp initial_high [7] ; the initial line state is flipped!
3335

3436
% c-sdk {

0 commit comments

Comments
 (0)