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

General • HOW TO LINKING TWO PIO BLOCKS?

$
0
0
I want to use PIO (using C language) to read the level on a pin and decode it.
However, the decoding logic is relatively complex, and 32 instructions are not enough to achieve complete parsing. So I want to use two PIOs to make the total number of instructions 2*32=64.
My functional requirement is to configure a DATA pin as a decoding pin, which requires the execution of IN/WAIT/JMP instructions.
I expect to use a SYNC pin as a bridge between two PIOs. When the pin level is high, execute program A; when the pin level is low, execute program B. This will require the use of WAIT and SET instructions for the SYNC pin.
The pseudo code is as follows:

Code:

.program await pins 1func_aset pins 0%c-sdk%.program bwait pins 0func_bset pins 1%c-sdk%
But this approach seems to introduce new problems:
I need to initialize the SYNC pin in both PIO blocks through pio_gpio_init(), and both need to support IN(for wait)/SET instructions, which will cause gpio_set_function() and other functions to be called repeatedly. I don't know whether such repeated function calls will overwrite the previous configuration or take effect at the same time.
I tried it according to this logic, but the program function is not implemented at present (because I can only check it through PRINT RX_FIFO data, but there is no PRINT at present, and I haven't located which process caused the problem yet).
Is there anyone who has experience in linking two PIO blocks and can give me some suggestions? Thank you!

Statistics: Posted by Norcor — Wed Aug 07, 2024 1:14 pm — Replies 0 — Views 21



Viewing all articles
Browse latest Browse all 7403

Trending Articles