element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
ZedBoard Hardware Design SPI pin mapping when use PMOD
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 3 replies
  • Subscribers 353 subscribers
  • Views 717 views
  • Users 0 members are here
Related

SPI pin mapping when use PMOD

Former Member
Former Member over 11 years ago

Hello guys~
I designed a SPI design and connected to PL(EMIO).
Because I am using zedboard and PMOD module from Maxim.(SPI module)
But my design doesn't work, so I am checking what I have done.
I found 6pins of SPI pin declaration, but I am not sure I did make a good connection to physical pin.



1. Could you let me know which pin should be connected with SS, MOSI, MISO, SCK?
(*)I am using only 1 SPI as a master mode.

    spi_0_io0_io : inout STD_LOGIC;
    spi_0_io1_io : inout STD_LOGIC;
    spi_0_sck_io : inout STD_LOGIC;
    spi_0_ss1_o : out STD_LOGIC;
    spi_0_ss2_o : out STD_LOGIC;
    spi_0_ss_io : inout STD_LOGIC



2. Should I have to set and enable every pin using "set direction and discrete write" funtion?



3. In the middle of debugging, I found my process is pending, actually wait for transaction permanetly..
Could it be a result of wrong pin connection?

*part of code
-----------------------------------------------------
//Wait for transaction to complete.  Check to see if Tx_Empty flag is set before proceeding.
ttwhile( !(XSpiPs_ReadReg( unPeripheralAddressSPI, 0x64 ) & 0x00000004));
------------------------------------------------------

*whole code

int SpiRW( u32 unPeripheralAddressSPI, unsigned int unCPHA, unsigned int unCPOL, u8* auchWriteBuf, u8* auchReadBuf, int unNumBytes, u8 uchCsActiveHigh )
/**
* brief       Perform a SPI read or write.
* par         Details
*              This function provides a combination SPI Read and Write to the chosen SPI port in the design
*              CPHA and CPOL can be set to 0 or 1
*              Pointers are provided to u8 buffers containing the data to be written and received
*              Data in the auchWriteBuf will be clocked out (MSB first) onto the MOSI pin
*              Data from the MISO pin will be placed into the auchReadBuf
*              uchCsActiveHigh==TRUE allows SS configurations to be used
*              uchCsActiveHigh==FALSE allows SS# configurations to be used
*
* param[in]   unPeripheralAddressSPI         - @help
* param[in]   unCPHA             - phase of SCK (edge to trigger on). 0=Leading edge, 1=Trailing edge
* param[in]   unCPOL             - polarity of SCK. 0=Active high, 1=Active low
* param[in]   auchWriteBuf       - pointer to write data buffer
* param[in]   auchReadBuf        - pointer to read data buffer
* param[in]   unNumBytes         - number of bytes to transfer
* param[in]   uchCsActiveHigh    - polarity of slave select 0=active low, 1=active high
*
* retval      Always returns 0
*/
{
tint i;
tunsigned int unControlData = 0x00000186;

t//If CPHA or CPOL = 1, we need to set the corresponding bits in the control register
tunControlData = unControlData | (unCPHA << 4);
tunControlData = unControlData | (unCPOL << 3);

t//Write config data to SPICR.  We need the inhibit bit=1.
tXSpiPs_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);

t//Deassert CS to 1 to ensure SPI slave is inactive
tif( uchCsActiveHigh )
ttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFE);
telse
ttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);

tfor( i = 0; i < unNumBytes; i++)
t{
ttif( auchWriteBuf != 0 )
tt{
ttt//Write data to SPIDTR.  This is the data that will be transferred to the SPI slave.
tttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x68, auchWriteBuf[ i ]);
ttt//Debug//printf( "Write %02x; ", auchWriteBuf[i]);
tt}
ttelse
tt{
ttt//Write data to SPIDTR.  This is the data that will be transferred to the SPI slave.
tttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x68, 0x00);
tt}

tt//Write config data to SPICR.  We need the inhibit bit=1.
ttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);

tt//Assert CS for our PMOD part
ttif( uchCsActiveHigh )
tttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
ttelse
tttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFE);

tt//Un-inhibit our SPI master to transfer the data
ttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x60, unControlData & 0xFFFFFEFF);

ttprintf( "Read %02xr
", XSpiPs_ReadReg( unPeripheralAddressSPI, 0x64 ));
tt//Wait for transaction to complete.  Check to see if Tx_Empty flag is set before proceeding.
ttwhile( !(XSpiPs_ReadReg( unPeripheralAddressSPI, 0x64 ) & 0x00000004));


tt//Inhibit SPI master to prevent further action
ttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);

tt//Read received data
ttif( (auchReadBuf != 0) )
tt{
tttauchReadBuf[ i ] = XSpiPs_ReadReg(unPeripheralAddressSPI, 0x6C);
ttt//Debug//printf( "Read %02xr
", auchReadBuf[i]);
tt}
t}
tif( uchCsActiveHigh )
ttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFE);
telse
ttXSpiPs_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
treturn 0;
}

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Once you have made the SPI interface on the Zynq Processing system 'External' and let Vivado 'Create HDL Wrapper' the tools should have instantiated IO buffers for you in the HDL wrapper. Now you will want to connect the 'io' signals required to the correct pins, with the correct  IO standard (LVCMOS33 in this case) by creating a constraints file either directly or using the IO Planning view after synthesis.

     

    Depending on the SPI PMOD you are using you will want to connect to spi_0_sck_io , spi_0_io0_io, probably spi_0_ss_io , and possibily spi_0_io1_io (if you are reading back from the SPI PMOD). If your PMOD uses more than one chip select you will need to connect that as well. The pin assignments depend on the pin out of your PMOD.

     

    Maxim has example code for most of their PMODs in the zedboard community projects area although most of them are written to use the axi_spi cores rather than the ps_spi, so you may need to make some modifications.

     

    Which Maxim PMOD are you using?

     

    -Gary

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Gary, Thanks for you fast reply.
    I am using MAX31723 and other PMOD modules based on SPI.
    What is the difference btw axi_spi and ps_spi?
    Base on my understanding axi_spi is implemented on PL side and ps_spi is PS side...
    Am I right?


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Hi,

    Did you find a good tutorial/example for the MAX31723 (for the Zedboard, but I'll take anything in Vivado 2014.x)?  If so, I am interested in seeing it.  I have tried to follow "Zynq Workshop for Beginners" by Rich Griffin but can't get it to work.  I can generate a bitstream and launch the application in SDK, but the program hangs when I am running it on the FPGA.

    As far as my debugging has gone, it looks like the program hangs sometime after the first or second peripheral initialization command.  I have tried going back and verifying the constraints, but the workshop centered around a one-shot run for completion and I am uncertain if I have the correct design when starting that step.  This makes debugging all that more miserable, and maybe impossible.

    Again, any tutorial centering on talking to a PMOD (preferably using SPI on the PL side) would be much appreciated.

    Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube