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 zsolti92104
Visitor
898 Views
Registered: ‎07-31-2018

SPI EMIO controller in SDK

Jump to solution

Hello,

 

I am really new in SoC-s, and i want to create a system where i use the Zynq 7020 (on Pynq) to send and read SPI data throug EMIO pins. I have created the block design in Vivado where i use the SPI0 with EMIO pins, and i created External ports for the SPI0. I have also created the constraints file for these pins. I exported the project into SDK but i dont have a clue how to set (Which command) the direction of the created SPI_0_io0_io and SPI_0_io1_io and SPI_0_ss_io, and how to control (read write) these pins in the SDK with C language. I looked the examples and i tried to write an SPI controller code where i externally connect the MISO pin to ground so that i read full zeroes into the Receive buffer, but the read buffer does not change (i dont use interrupt).

Here are the design pictures:

 

zynq_ps.PNG

constraints.PNG
code.PNG
What can be wrong with the code or design? I also attached the C code.

 

Thank you in advance!

Best regards,
Zsolt.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Scholar ronnywebers
Scholar
867 Views
Registered: ‎10-10-2014

Re: SPI EMIO controller in SDK

Jump to solution

@zsolti92104

 

I don't have immediately code at hand, but you might want to take a look at :

 

1) this blog post from the Microzed Chronicles

2) this interesting tutorial. Especially chapter 4 and 9, which deal with SPI (but all others are also very interesting). You can find the source files / exercises here on github

 

also you might need to wait much longer in your for loop, the ARM processors are really fast :-) you can put some sleep function there and wait a second to start with.

 

most SPI interfaces have separate MOSI (out for the Zynq)  and MISO pins (in for the Zynq), so their direction is fixed and you do not need to configure it afaik.

 

do you see anything on the SS, MOSI or CLK pins on an oscilloscope?

 

edit : about the constraints, have a look at this post. Also check UG585 (Zynq TRM) par. 17.5 about the EMIO routing and naming conventions for constraints.

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
3 Replies
Highlighted
Scholar ronnywebers
Scholar
868 Views
Registered: ‎10-10-2014

Re: SPI EMIO controller in SDK

Jump to solution

@zsolti92104

 

I don't have immediately code at hand, but you might want to take a look at :

 

1) this blog post from the Microzed Chronicles

2) this interesting tutorial. Especially chapter 4 and 9, which deal with SPI (but all others are also very interesting). You can find the source files / exercises here on github

 

also you might need to wait much longer in your for loop, the ARM processors are really fast :-) you can put some sleep function there and wait a second to start with.

 

most SPI interfaces have separate MOSI (out for the Zynq)  and MISO pins (in for the Zynq), so their direction is fixed and you do not need to configure it afaik.

 

do you see anything on the SS, MOSI or CLK pins on an oscilloscope?

 

edit : about the constraints, have a look at this post. Also check UG585 (Zynq TRM) par. 17.5 about the EMIO routing and naming conventions for constraints.

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Visitor zsolti92104
Visitor
791 Views
Registered: ‎07-31-2018

Re: SPI EMIO controller in SDK

Jump to solution

Thak You Ronny! After some time i have managed to solve the problem. First I needed to change the SS signal to forced write a 1 on the line because without that it did not start the communication. After with oscilloscope i figured out that the SPI_io_0 was the MISO and SPI_io_1 was the mosi, but before that i thought the opposite.

Thank you for your answer and the useful links.

Have a nice day!

0 Kudos
Scholar ronnywebers
Scholar
774 Views
Registered: ‎10-10-2014

Re: SPI EMIO controller in SDK

Jump to solution

regarding the 'SS' pin, in your case this must indeed be connected to '1', it is mentioned in the TRM (though it should be explained better why)

 

spi SS.jpg

 

the SSIN line is meant to be used in 'multi-master' mode or 'slave' mode, so when another SPI master wants to send data to you. I think when using MIO pins, the SSIN is automatically pulled high, but with EMIO pins, this INPUT is low, so the SPI unit thinks it must receive data from an external device.

 

it's in the small details :-)

 

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos