raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.25k stars 838 forks source link

Manual push not pushing in FIFO? Update: only 1 instruction is executed #1683

Closed kwahoo2 closed 2 months ago

kwahoo2 commented 3 months ago

Hi,

This my be my stupid mistake, but:

If I set autopush:

sm_config_set_in_shift(&c, true, true, pin_count); //auto push

and:

.wrap_target
    in pins, 21 ; read 21 pins into ISR register
.wrap

the RX FIFO is filed with data. So far, so good.

But if I disable autopush:

sm_config_set_in_shift(&c, true, false, pin_count); //do not auto push

and add manual push in the pio code:

.wrap_target
    in pins, 21 ; read 21 pins into ISR register
    push
.wrap

FIFO stays empty. Adding noblock or iffull does not change anything

I use the latest master.

Full code in the attachment, FIFO level is printed via USB serial:

n = pio_sm_get_rx_fifo_level(pio, sm);
printf("fifo level is: %u\n", n);

pio-reader.zip

kwahoo2 commented 2 months ago

Now this is getting weird. It seems that only 1 instruction in .wrap_target .wrap block is executed.

Eg. this pushes the ISR register to FIFO:

.wrap_target
    push 
.wrap 

But this does not:

.wrap_target
    in pins, 21
    push 
.wrap

If autopush is enabled the issue still can be triggered, eg this will not push the ISR in FIFO (mov y, y can be replaced with any instruction):

.wrap_target
    mov y, y
    in pins, 21
.wrap
kwahoo2 commented 2 months ago

Ok, found it. It was my mistake, accidentally left sm_config_set_wrap() function call.