I'm usîng something like:
Although pio_sm_set_pins(), pio_sm_set_pindirs_with_mask(), etc., do similar things (in my case I've used mov or out instead of set because I've used directive .out only but not .set).
Code:
// set destination register immediately, possibly using osr (i.e. not fool proof)static inline void dest_init(PIO pio, uint sm, enum pio_src_dest dest, uint value) { if (dest == pio_pc) pio_sm_exec(pio, sm, pio_encode_jmp(value)); else if (value < 32 && (dest == pio_x || dest == pio_y)) pio_sm_exec(pio, sm, pio_encode_set(dest, value)); else if (value == 0) pio_sm_exec(pio, sm, pio_encode_mov(dest, pio_null)); else if (value == ~0) pio_sm_exec(pio, sm, pio_encode_mov_not(dest, pio_null)); else { pio_sm_put(pio, sm, value); pio_sm_exec(pio, sm, pio_encode_pull(false, false)); if (dest != pio_osr) pio_sm_exec(pio, sm, pio_encode_out(dest, 32)); }}Code:
… if (pio_sm_init(pio, sm, initial_pc, config) != PICO_OK) …; // empty FIFO now dest_init(pio, sm, pio_y, 0); // initial sub-frame counter dest_init(pio, sm, pio_isr, 192*2 - 1); // sub-frames per block dest_init(pio, sm, pio_pins, 0); dest_init(pio, sm, pio_pindirs, ~0); …Statistics: Posted by PicoTinker — Wed Oct 16, 2024 8:59 am