Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4955

General • Re: Maybe a stupid question about the PULL instruction of PIO

$
0
0
What do you mean when you say " push one byte every 1 second to the Tx FIFO"?

You can't push bytes to the FIFO, it's a FIFO of words.

Of course, you can push a word where only the low 8 bits are used, or if you use autopull or "pull ifempty" you can push a word and have the PIO program consume it as 4 bytes (with OUT <somewhere>,8).

But if you are calling pio_sm_put_blocking() and think that pushes 4 separate bytes, that's wrong. It pushes one 32-bit value, and it's up to the PIO program to interpret those bits according to your design - maybe you want to write 24-bit values to the FIFO and there are two pins, so it consumes the data two bits at a time: that combination would be achieved with sm_config_set_out_shift(&c, whatever, whatever, 24) and then OUT PINS,2 in the program. There's still 32 bits in every entry in the FIFO, but now you are setting up the PIO machinery to count them, discarding 8 and using the rest 2 at a time.

Note that the plain ordinary PULL instruction is rare - obviously you can use it if you want to, but it's nearly always better to either use autopull or at least use PULL ifempty.

Finally, what's the purpose of your OUT Y,32 instruction? This isn't really doing anything in your current program, apart from providing a delay - it's shifting 32 bits from OSR (ie. the whole of it) into Y, but since you aren't using autopull and don't use the value in Y this doesn't do anything. If you turned on autopull, you could delete the individual pull instruction and this OUT Y,32 would have the same effect and saves an instruction (which is why autopull is almost always used - running out of instructions is the biggest constraint on PIO programs).

Statistics: Posted by arg001 — Tue Feb 27, 2024 4:05 pm



Viewing all articles
Browse latest Browse all 4955

Trending Articles