Raspberry Pi Zero to P2 communications over SPI bus
Rayman
Posts: 14,646
I'm looking into using Raspberry Pi Zero as a GPU for P2...
Want to use SPI bus to get high speed.
I'm using wiringPi right now, which supports up to 32 MHz.
Here's my initial stab at this in C++ from raspi side and spin2 for P2 side.
It seems like I need two added delays in there that depend on the SPI bus speed.
I was able to get to 5 MHz using this approach.
Not horrible, but would like to do better in the future.
This is with raspi being the SPI master, which is a bit of an issue.
I think what I'll try next is using a raspi GPIO to tell the raspi that a command is ready to be issued and to start a 32-bit transfer.
Still thinking about best way to do this...
Want to use SPI bus to get high speed.
I'm using wiringPi right now, which supports up to 32 MHz.
Here's my initial stab at this in C++ from raspi side and spin2 for P2 side.
It seems like I need two added delays in there that depend on the SPI bus speed.
I was able to get to 5 MHz using this approach.
Not horrible, but would like to do better in the future.
This is with raspi being the SPI master, which is a bit of an issue.
I think what I'll try next is using a raspi GPIO to tell the raspi that a command is ready to be issued and to start a 32-bit transfer.
Still thinking about best way to do this...
Comments
There are companies selling LCD modules like ' WS 320x240 3.2 inch Touch Screen TFT LCD for Raspberry Pi 125MHz High-Speed SPI' and those have Pi drivers, so maybe you could look at those drivers
for ideas ?
or even consider making P2 'look like' one of those LCDs so it just discards the config info, and accepts the streamed pixels ?
Of course, those are focused on one-way traffic, whilst a GPU may be more two-way ?
But even if that wasn't an issue then the lack of a truely synchronous external I/O clock on the prop2 means you would still strike problems as you approach sysclock/3. If this was the limiting factor then sysclock/4 would be the recommended max SPI clock rate with prop2 as slave.
Sooo ... apparently there is one serial port on the Pi's that can be configured as a slave. Doing this would provide the best opportunity for a speed up.
I think this will be the solution to my ringbuffer problem, but I hadn't had any time to check this out, yet.
It might help for spi slave code?
Mike
So the first problem with the prop2 being a slave is the limitation of the smartpin tx mode, due to the intermediary stages, cannot be compensated for when the prop2 is not controlling the SPI clock.
Short answer is, something like sysclock/8 is likely about as fast as you can get.