UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor amol_aeva
Visitor
1,910 Views
Registered: ‎01-23-2018

MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

I would like to use the SPI peripheral in the PS to communicate with an ADC that has an bidirectional SPI data pin (SDIO). The SPI pins are mapped to EMIO pins since the SPI device is hooked to PL pins.

So far I have instantiated an IOBUF with the following connections.

 

 

IOBUF sdio_buf (
  .I    (SPI_M0_io0_o),
  .IO   (sdio),
  .O    (SPI_M0_io1_i),
  .T    (SPI_M0_io0_t) 
);

How do you write a driver to control the tristate signal such that the interface works with an SDIO pin instead of separate MOSI and MISO pins?

0 Kudos
8 Replies
Xilinx Employee
Xilinx Employee
1,879 Views
Registered: ‎02-26-2014

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

Hi,

 

When the interface has a tri-state logic, and tri-state signal is coming from the controller, you need not do anything specific to that in the software/driver. The SPI controller will take care of asserting this signal when ever required.

 

There is a driver available already.

 

Regards,

Ravi

Explorer
Explorer
1,875 Views
Registered: ‎06-19-2015

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

Hi,

 

Your IOBUF instantiation is correct. But make sure of which tri-state you have to connect? and weather to connect directly or negation of it?

 

IOBUF sdio_buf (
  .I    (SPI_M0_io0_o),
  .IO   (sdio),
  .O    (SPI_M0_io1_i),
  .T    (SPI_M0_io0_t)  // .T    (SPI_M0_io1_t) //   .T    (~SPI_M0_io0_t)  // .T    (~SPI_M0_io1_t) 
);

 

Thanks

Madhu

0 Kudos
Visitor amol_aeva
Visitor
1,871 Views
Registered: ‎01-23-2018

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

Issue I'm seeing is that the tristate signal is never going high. Is there something I have to tell to the driver to indicate that I want enable the tristate?

0 Kudos
Xilinx Employee
Xilinx Employee
1,864 Views
Registered: ‎02-26-2014

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

Hi,

 

Its all up to the software application code. There are some examples in SDK installation area, if you wan tto have a look.

From software application, code has to initialize the controller and initiate transfers.

 

Regards,
Ravi

 

0 Kudos
Visitor amol_aeva
Visitor
1,823 Views
Registered: ‎01-23-2018

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

The issue is that Xilinx's XSpiPs driver code does not appear to have any concept of data direction.

 

When a SPI is enabled in the PS, the PS module has input, output, and tristate-enable ports for each of SCLK, M, S, and SS. Thus I assume that the hardware SPI engine is capable of supporting 3-wire SPI. But there is no data-direction argument to XSpiPs_Transfer() (or XSpiPs_PolledTransfer()). Nor is there any sort of data-direction control-bit in any of the structures defined in xspips.h. The code provided by Xilinx has no mechanism for controlling any of these tristate-enable signals (apart from XSPIPS_MASTER_OPTION, which sets whether the PS-SPI engine is a master or a slave).

 

To work around this, we've created a register bit in the PL, which software writes to control the tristate-enable of MOSI. For 3-wire read transactions, software uses XSPIPS_FORCE_SSELECT_OPTION and we modified XSpiPs_PolledTransfer() to do two transfers (a command/address write, followed by a data read) with assertion of the tristate-enable in between, with slave-select asserted through the entire transaction. This is obviously a bit "hacky" and would hope a more elegant way is possible.

0 Kudos
Scholar ericv
Scholar
1,811 Views
Registered: ‎04-13-2015

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

@amol_aeva

 

Have you considered using QSPI instead of the SPI?

The SPI standard is 2 uni-directional data lines.

QSPI is an extension to SPI and it handles 2 & 4 bi-directional data lines

 

Regards

0 Kudos
Visitor amol_aeva
Visitor
1,768 Views
Registered: ‎01-23-2018

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

Are you saying to use the QSPI Master to talk to the SPI slave?

Even if this was possible, I have 3 such slaves and there is only 1 QSPI slave select line. Also I need to route the SPI signals over EMIO which didn't seem possible when I tried setting it in the GUI.

0 Kudos
Xilinx Employee
Xilinx Employee
1,705 Views
Registered: ‎02-26-2014

Re: MPSOC - Use PS SPI to communicate with a slave with bidi data (sdio) through EMIO

Hi,

 

When you configure the controller to be a master, MOSI will be an output, and MISO will be an input. And is same as SPI spec says.

 

Coming to the driver APIs, for example XSpiPs_PolledTransfer(), which has to be called from SPI master software, has no direction as you said. Because it performs both write and read transfer at a time, and that is the reason why you can provide read_buffer and write_buffer to the API. When this API gets executed SPI master sends the data in write_buffer and fills the read_buffer with data sent by SPI slave. The user has to make sure that, the TXFIFO of SPI slave is filled and is ready to sent the data before this API gets executed on SPI master.

 

Regards,

Ravi

0 Kudos