element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Achievement Levels
    • Benefits of Membership
    • Feedback and Support
    • Members Area
    • Personal Blogs
    • What's New on element14
  • Learn
    Learn
    • eBooks
    • Learning Center
    • Learning Groups
    • STEM Academy
    • Webinars, Training and Events
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Arduino Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Project Groups
    • Raspberry Pi Projects
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Or 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development Error running PS SPI through PMOD - any help appreciated
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Avnet Boards Forums requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 7 replies
  • Subscribers 175 subscribers
  • Views 305 views
  • Users 0 members are here
Related

Error running PS SPI through PMOD - any help appreciated

Former Member
Former Member over 10 years ago

Hello,

Are you able to help me alittle bit with my SPI? I am facing alot of trouble with it.
I directed my SPI1 to PMOD, then got some code running. I am connecting a 8 bit shift register to the PMOD and im sending 1 byte and reading 2 bytes - which means that every data the data i send, must be received back on the 2nd location of the buffer.

This WORKS - but only sometimes.! i run the code, and it returns without any errors, but when i run it again, it gets stuck in the XSpiPs_PolledTransfer command, and im not sure why.. attached in the function.

I will really appreciate it if you could take a look at it!!!

Thank you in advance..



#define DS26518_SPI_SELECTt0x01

/**
int SpiPsreadIDR(u16 DeviceId)
{
tint Status;
tu8 writeBuffer2[2];
tu8 readBuffer2[2];

treadBuffer2[0]=0x00;
treadBuffer2[1]=0x00;
treadBuffer2[2]=0x00;
twriteBuffer2[0]=0xBF;
twriteBuffer2[1]=0xAA;

txil_printf("Initializing config
r");
tXSpiPs_Config *SpiConfig;

tSpiConfig = XSpiPs_LookupConfig(DeviceId);
tif (NULL == SpiConfig) {
ttreturn XST_FAILURE;
t}
tStatus = XSpiPs_CfgInitialize(&Spi, SpiConfig, SpiConfig->BaseAddress);
tif (Status != XST_SUCCESS) {
ttreturn XST_FAILURE;
t}

tXSpiPs_SetOptions(&Spi, XSPIPS_MASTER_OPTION |
ttt   XSPIPS_FORCE_SSELECT_OPTION);

tXSpiPs_SetClkPrescaler(&Spi, XSPIPS_CLK_PRESCALE_64);
tXSpiPs_SetSlaveSelect(&Spi, DS26518_SPI_SELECT);

tXSpiPs_PolledTransfer(&Spi,writeBuffer2,readBuffer2,2);

txil_printf("IDR value is: MSB: %x
r", writeBuffer2[0]);
txil_printf("IDR value is: LSB: %x
r", writeBuffer2[1]);
txil_printf("IDR value is: MSB: %x
r", readBuffer2[0]);
txil_printf("IDR value is: MSB: %x
r", readBuffer2[1]);

treturn XST_SUCCESS;
}

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

    Hi Joe,

    I've seen this with several of the library routines. A power cycle of the board between runs usually fixes it. Otherwise, you end up debugging the library routines. Been there, not fun.

    Good luck,
    Mike

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

    yeah not fun at all!
    However, even when i power off the board then power it on again, sometimes it still doesnt work!

    Thank you Mike for the help. Where can i find the 14.6 libraries?

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

    You have to have installed ISE 14.6.
    In the XSDK select the "Xilinx Tools" menu.
    Select "Repositories".
    Under "SDK Installation Repositories" you will see where on your system the libraries for the current version are stored.

    On mine, I change 14.4 to 14.6 to access the path for the latest libraries.

    Mine are at,
    C:Xilinx14.6ISE_DSEDKswXilinxProcessorIPLibdriversspips_v1_05_asrc

    Adding the 14.6 repositories should load the latest drivers into your build.

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

    Hi Mike,

    Thank you, i will update my tools or/and update and move in to the newer library.
    i will let you know what happens by then (hopefully tomorrow or the day after).

    So far it seems that the TX fifo is becoming full but its not sending data as the SPI controller wont innitiate SCLK. Does this problem sound familiar to you in any way?

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

    I remember I ran into a device that was active high instead of active low. It seems to me that it had similar symptoms. If your device is active low then ignore the rest of this comment.

    Since I was using EMIO, I just inverted the select bit on the way to the device. With MIO it's a more difficult problem.

    0x0E might work to deassert the device.
    0x0F might work to assert the device.

    However, XSpiPs_SetSlaveSelect() will not accept these values. You'll have to write the register yourself in the same way as the routine itself.

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

    Hi Mike, you were right all along.
    Apparently the problem was the tools version/ library/drivers version that i was using.

    I upgraded my tools to 14.6 (from 14.2) and used the same code even - everything works without any problems.

    The only issue with the SPI is the SS0 (chip select 0). When directing the SPI1 to PS PMOD (MIO), SS0 will not work! and it will hang your SPI prepherial. You must instead use SS1 and SS2. or use the SPI EMIO connection.

    Thank you for the help.. and i hope this topic helps others!

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

    Hi Yousef,

    Glad to see the updated libraries helped. I found the same thing with a problem Iu2019ve been working on for over a month.

    Iu2019m not sure why you say that SS0 does not function via MIO. Itu2019s location on the pMod connector is JE1. This is right where you want it to be, at least for the SPI pMod devices Iu2019ve tested.

    Have you read the ug585-Zynq-7000-TRM.pdf section on SPI? It contains programming examples and wiring diagrams. Iu2019ve found it to be quite useful. It shows SS0 being used via MIO.

    Regards,
    Mike

    • 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 © 2023 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