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

General • Re: Multiple devices on the SPI bus

$
0
0
Fortunately, the Pico series has a very simple solution to your dilemma. You can implement an SPI interface using PIO (look in the PIO examples folder for code). So you now have a separate SPI interface for each set of pins.

P.S. A bit off-topic, but I've found the W5500 to work pretty well with the Pico2., provided you can live with maximum 8 open connections.
So, in this case, I could have a 'standard' SPI#1 interface on (8,10,11), and a PIO SPI interface on (12,14,15) and use appropriate GP pins for the CS lines as at present, and this would leave SPI#0 free for the WS5500. I will give it a try and see how it goes.
I guess it's not too dissimilar to the SoftSPI stuff in Arduino (except better implemented on a PIO) and as you point out, less likely to cause issues on different revisions of silicon.

I see that the example has write_blocking, read_blocking, and wri,te_read_blocking, which is almost everything I need.

There's a comment in the PIO source, that the SCK period is 4 clock cycles, so for 8 bit transfers, that would be at least 32 clock cycles, I think.
I am assuming that by setting clkdiv, I can effectively set the SPI baud. I've not done anything with PIO before, (although I see the pio_spi_init function does most of what I would want), so I am a little in the dark on this.

How would I go about setting, say, 1MHz bus speed, which should be fast enough for a touchscreen?
The clkdiv is operating on the PIO clock rather than the ARM one, I assume, so what would that be by default?

I'm also still curious to know what happens if I set GPIO_FUNC_SPI for more than one SPI1 pin at the same time, but lacking a 'scope or other useful tools, I don't feel like experimenting too much with it...

Statistics: Posted by SteveSpencer — Wed Nov 19, 2025 5:36 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles