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

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

$
0
0
Thanks for the replay.

What do you mean when you say " push one byte every 1 second to the Tx FIFO"?
-> Of course, I knew it push word to FIFO. I did like the example in official "i2c.pio", every time use combined word, which consist of one byte (user data want to send) + some instruction bits to write into FIFO.

I have found a solution, although still not understand why it worked...

I wrote a test PIO, if pull got 0 it will not send, else send a pulse.
when I write pio_sm_put_blocking(pio, sm, (uint32_t)1);
I got unexpected 3 pulses, which is expected one, like this...
tx 1.jpg
if I write pio_sm_put_blocking(pio, sm, (uint32_t)0);
tx 0.jpg
The pulse decreased by one...

It seems that some strange data was input into the FIFO, which triggered the pull instruction more than one time.

The called function is defined like some example, such as uart_rx.pio, using a inline function definition in .PIO.
After try...I found if I write the function with a macro, like this:

Code:

#define pio_tx_put(pio, sm, data) { \    while (pio_sm_is_tx_fifo_full(pio, sm)); \    *(io_rw_32 *)&pio->txf[sm] = data; \}\
All unexpected FIFO data disappeared. I got expected output waveform...Until now, it worked well...
Maybe it was caused be the unofficial build environment (I used Vsc + PlatformIO)...later, I will try the official method.

Statistics: Posted by H.Hou — Wed Mar 06, 2024 5:56 am



Viewing all articles
Browse latest Browse all 4909

Trending Articles