Skip to content

Commit 98422e1

Browse files
Wren6991kilograham
authored andcommitted
Fix garbage at start when doing repeated capture with non-po2 sample size
1 parent 475a726 commit 98422e1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pio/logic_analyser/logic_analyser.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ void logic_analyser_init(PIO pio, uint sm, uint pin_base, uint pin_count, float
6565
void logic_analyser_arm(PIO pio, uint sm, uint dma_chan, uint32_t *capture_buf, size_t capture_size_words,
6666
uint trigger_pin, bool trigger_level) {
6767
pio_sm_set_enabled(pio, sm, false);
68+
// Need to clear _input shift counter_, as well as FIFO, because there may be
69+
// partial ISR contents left over from a prevoius run. sm_restart does this.
6870
pio_sm_clear_fifos(pio, sm);
71+
pio_sm_restart(pio, sm);
6972

7073
dma_channel_config c = dma_channel_get_default_config(dma_chan);
7174
channel_config_set_read_increment(&c, false);
7275
channel_config_set_write_increment(&c, true);
7376
channel_config_set_dreq(&c, pio_get_dreq(pio, sm, false));
7477

7578
dma_channel_configure(dma_chan, &c,
76-
capture_buf, // Destinatinon pointer
79+
capture_buf, // Destination pointer
7780
&pio->rxf[sm], // Source pointer
7881
capture_size_words, // Number of transfers
7982
true // Start immediately

0 commit comments

Comments
 (0)