From 4f64f3af80f36db9ff3ff0c65a7f47b5f1b496f1 Mon Sep 17 00:00:00 2001 From: Tom Messick Date: Wed, 21 Apr 2021 13:42:57 -0700 Subject: [PATCH] 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 --- .../differential_manchester.pio | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pio/differential_manchester/differential_manchester.pio b/pio/differential_manchester/differential_manchester.pio index b10f2b9..a9e825d 100644 --- a/pio/differential_manchester/differential_manchester.pio +++ b/pio/differential_manchester/differential_manchester.pio @@ -7,7 +7,7 @@ .program differential_manchester_tx .side_set 1 opt -; Transmit one bit every cycles. In each bit period: +; Transmit one bit every 16 cycles. In each bit period: ; - A '0' is encoded as a transition at the start of the bit period ; - A '1' is encoded as a transition at the start *and* in the middle ; @@ -16,19 +16,21 @@ public start: initial_high: - out x, 1 side 1 ; Start of bit period: always assert transition - jmp !x high_0 [6] ; Test the data bit we just shifted out of OSR + out x, 1 ; Start of bit period: always assert transition + jmp !x high_0 side 1 [6] ; Test the data bit we just shifted out of OSR high_1: - jmp initial_high side 0 [7] ; For `1` bits, also transition in the middle + nop + jmp initial_high side 0 [6] ; For `1` bits, also transition in the middle high_0: jmp initial_low [7] ; Otherwise, the line is stable in the middle initial_low: - out x, 1 side 0 ; Always shift 1 bit from OSR to X so we can - jmp !x low_0 [6] ; branch on it. Autopull refills OSR for us. + out x, 1 ; Always shift 1 bit from OSR to X so we can + jmp !x low_0 side 0 [6] ; branch on it. Autopull refills OSR for us. low_1: - jmp initial_low side 1 [7] ; If there are two transitions, return to -low_0: ; initial_low on the next bit. If just one, + nop + jmp initial_low side 1 [6] ; If there are two transitions, return to +low_0: jmp initial_high [7] ; the initial line state is flipped! % c-sdk {