PYNQ: PYTHON PRODUCTIVITY

Dedicated SPI pin numbers for PYNQ-Z1 IOP app

Hello. I’m currently writing an application for the Arduino IOP on the PYNQ-Z1 to communicate with a sensor via SPI. I have the sensor connected to the SPI header and am using the Xilinx-provided SPI library (boards/sw_repo/pynqmb/src/spi.h); however, I cannot find any mention in the docs or examples of what pin numbers are associated with the dedicated SPI pins to be passed as args to the spi_open() function.

Right now, I’m using the following pin assignments:

const unsigned int SPICLK_PIN = 13;
const unsigned int MISO_PIN = 12;
const unsigned int MOSI_PIN = 11;
const unsigned int SS_PIN = 10;

And I’m invoking spi_open like so:

spi_device = spi_open(SPICLK_PIN, MISO_PIN, MOSI_PIN, SS_PIN);

I’m thus far unable to communicate with the sensor, and the MicroBlaze program seems to consistently hang on the first attempted SPI transfer. For reference, here is my IOP program source and here is the associated Python wrapper as well.

Any help will be most appreciated.

You need to first find out which spi controller you want to use. If it is not SPI controller 0, you will have to use spi_open_device() instead (https://github.com/Xilinx/PYNQ/blob/master/boards/sw_repo/pynqmb/src/spi.c#L64).

Then after open device, you can set up pins.

set_pin(spiclk, SPICLK0);
set_pin(miso, MISO0);
set_pin(mosi, MOSI0);
set_pin(ss, SS0);

Am I using the correct pin numbers for the dedicated SPI header though?

Pins are correct, but it might be on the other SPI controller. There are 2 SPI controllers, one connected to the dedicated header pin, the other connected to pin 10-13.