So I have some Raspberry Pico PIO code. There was a branch that wasn't working; it was only yielding x = 2. As an afterthought I refactored it, in a way that shouldn't have changed the end result, but it did. Here's the former code:
...
jmp pin rd side 0b0101 [1]
set x, 0b010 side 0b0101 [1]
jmp rdx side 0b0101 [1]
rd:
set x, 0b100 side 0b0101 [1]
rdx:
...
and here's after the refactor.
...
set x, 0b100 side 0b0101 [1]
jmp pin rd side 0b0101 [1]
set x, 0b010 side 0b0101 [1]
rd:
...
I think I've tested it three times both ways, and the former code only ever gives x = 2, while the latter code gives x = 2 or x = 4 depending on the value of the pin. (There's a little bit of assumption, here; the pin is set by an external chip and indicates the presence of data. I can get the second block to change reliably, though, and the first doesn't, and the only thing I change in the pico code is which of the two blocks are commented out, so....) The former, if pin
, it should jump to where it sets x = 4, skipping x = 2, and if not pin
, set x = 2, and then skip x = 4, yeah? The latter block similarly, but it starts off setting x = 4. But the second block acts like pin is sometimes 1 and sometimes 0, while the first block acts like pin is only ever 0. Do I misunderstand how jmp works or something??? Here's my full code. https://github.com/Erhannis/pico-examples/commit/a83ed67fdc4c3527e52b9462116f692309ae4d0f (There's also comms code for the FT232H I've connected to the Pico, which, incidentally, is the actual output I'm observing. The only thing I change in that code is whether I write any data from the computer to the FT232H. I test both versions of that code with both versions of the Pico code, so I don't think that's the problem.)
Also, should I instead ask this on the Electronics Stackexchange?