Skip to content

Commit 1862cc0

Browse files
committed
Capture for EOP after triggering decoder. Correct low duration too.
1 parent 9be1f3e commit 1862cc0

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/usb_rx.pio

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ pin_still_low:
3232
; Resync on rising edge
3333
pin_low:
3434
jmp pin pin_went_high
35-
pin_went_low:
3635
jmp pin pin_went_high
36+
pin_went_low:
3737
jmp pin pin_went_high
3838
jmp pin pin_went_high
3939
jmp pin pin_went_high
@@ -46,8 +46,8 @@ pin_still_high:
4646
; Jump to here on rising edge
4747
pin_went_high:
4848
mov isr, null [1]
49+
irq DECODER_TRIGGER ; Trigger NRZI decoder
4950
in pins, 1 ; Capture the pin to check eop.
50-
irq DECODER_TRIGGER ; Trigger NRZI decoder
5151
jmp pin pin_still_high
5252
jmp pin_went_low ; To adjust interval of decoder trigger, jump to pin_went_low (not pin_low)
5353

@@ -66,8 +66,8 @@ pin_still_low:
6666
; Resync on rising edge
6767
pin_low:
6868
jmp pin pin_went_high side db1
69-
pin_went_low:
7069
jmp pin pin_went_high side db1
70+
pin_went_low:
7171
jmp pin pin_went_high side db1
7272
jmp pin pin_went_high side db1
7373
jmp pin pin_went_high side db1
@@ -80,8 +80,8 @@ pin_still_high:
8080
; Jump to here on rising edge
8181
pin_went_high:
8282
mov isr, null [1] side db1
83+
irq DECODER_TRIGGER side db0 ; Trigger NRZI decoder
8384
in pins, 1 side db0 ; Capture the pin to check eop.
84-
irq DECODER_TRIGGER side db0 ; Trigger NRZI decoder
8585
jmp pin pin_still_high side db0
8686
jmp pin_went_low side db1 ; To adjust interval of decoder trigger, jump to pin_went_low (not pin_low)
8787

src/usb_rx.pio.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ static const uint16_t usb_edge_detector_program_instructions[] = {
3333
0x00cc, // 8: jmp pin, 12
3434
0x00cc, // 9: jmp pin, 12
3535
// .wrap
36-
0xa126, // 10: mov x, isr [2]
36+
0xa126, // 10: mov x, isr [1]
3737
0x0040, // 11: jmp x--, 0
38-
0xa1c3, // 12: mov isr, null
39-
0x4001, // 13: in pins, 1
40-
0xc004, // 14: irq nowait 4
38+
0xa1c3, // 12: mov isr, null [1]
39+
0xc004, // 13: irq nowait 4
40+
0x4001, // 14: in pins, 1
4141
0x00ca, // 15: jmp pin, 10
42-
0x0005, // 16: jmp 5
42+
0x0006, // 16: jmp 6
4343
};
4444

4545
#if !PICO_NO_HARDWARE
@@ -79,10 +79,10 @@ static const uint16_t usb_edge_detector_debug_program_instructions[] = {
7979
0xb126, // 10: mov x, isr side 1 [1]
8080
0x1040, // 11: jmp x--, 0 side 1
8181
0xb1c3, // 12: mov isr, null side 1 [1]
82-
0x4001, // 13: in pins, 1 side 0
83-
0xc004, // 14: irq nowait 4 side 0
82+
0xc004, // 13: irq nowait 4 side 0
83+
0x4001, // 14: in pins, 1 side 0
8484
0x00ca, // 15: jmp pin, 10 side 0
85-
0x1005, // 16: jmp 5 side 1
85+
0x1006, // 16: jmp 6 side 1
8686
};
8787

8888
#if !PICO_NO_HARDWARE

0 commit comments

Comments
 (0)