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

General • Re: How sideset works?

$
0
0
Your program doesn't give the expected effect due to the FIFOs.

At startup, the PIO program is stalled on the OUT X,32 (due to autopull).

C program then posts a word to the FIFO and the OUT instruction runs. The IN X,32 also runs immediately - there is plenty of space in the Rx FIFO so the word is pushed into the FIFO and the program wraps to the OUT X,32 which stalls again because the Tx FIFO is empty again.

C program reads the Rx FIFO after a while (pio_sm_get_blocking()) and this succeeds immediately because the PIO pushed a word some time ago, but has no effect on the PIO program because it is waiting for Tx rather than Rx; however, this ensures that the Rx FIFO never fills so the behaviour is the same every time round the loop in the C program.

So the LED will be off for one clock tick every second, which is indistinguishable from 'always on'.

You could get the effect you were expecting if you did four extra pio_sm_put_blocking(pio, sm, whatever); before entering the main loop: that would fill up the Rx FIFO so that the PIO program stalls on the next autopush.

Statistics: Posted by arg001 — Mon Jun 23, 2025 12:04 pm



Viewing all articles
Browse latest Browse all 7521

Trending Articles