Go to Post When I'm asked the question, "What is the most important computer language to learn to prepare me for a programming career?"; my answer is, "Your second one." - Greg McKaskle [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-02-2016, 08:24
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 56
gerthworm has a spectacular aura aboutgerthworm has a spectacular aura about
SPI Write Limitation

Hi All,

I've been working with some adafruit DotStar LED strands, driving them with the RIO's onboard SPI (using Java). I have them working, but to do so required I chunk the data to send into 128-byte sections, and call the spi.write() multiple times (once per section). This was done because the maximum return value I ever saw spi.write() give was 128.

I'm not horribly experienced with SPI - is this an implicit limitation of SPI in general? Or of the libraries and hardware we're using for FRC? Perhaps also I forgot to set up some buffer properly. Has anyone else seen this?

EDIT: Here's the code in question
DotStarsLEDStrip.java

Last edited by gerthworm : 08-02-2016 at 08:26.
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2016, 00:49
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,556
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: SPI Write Limitation

It looks like the limitation is in wpilib, rather then the roboRIO.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2016, 11:02
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 56
gerthworm has a spectacular aura aboutgerthworm has a spectacular aura about
Re: SPI Write Limitation

Seems like it. The bit of research I've done on this seems to indicate SPI is implemented on the FPGA, which I assume means any buffers are of fixed length. What those lengths are, however, I'm not really sure....
Reply With Quote
  #4   Spotlight this post!  
Unread 17-02-2016, 01:50
Peter Johnson Peter Johnson is online now
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 247
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: SPI Write Limitation

Quote:
Originally Posted by gerthworm View Post
Seems like it. The bit of research I've done on this seems to indicate SPI is implemented on the FPGA, which I assume means any buffers are of fixed length. What those lengths are, however, I'm not really sure....
Yes, it's a hardware limitation. Per the Zynq documentation [1], the SPI read and write FIFOs are 128 bytes deep. This matches the behavior you're seeing. Conceptually, functionality could be added to wpilib to do the outer loop for longer writes, but I think this case is rare enough (and there's multiple ways to do it, e.g. use interrupts to determine when to continue filling the FIFO, or periodically check), that it's better left to the user code to implement.

[1] http://www.xilinx.com/support/docume...q-7000-TRM.pdf, section 17.2.4.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
Reply With Quote
  #5   Spotlight this post!  
Unread 21-08-2016, 16:46
s5511's Avatar
s5511 s5511 is offline
Registered User
FRC #5511
 
Join Date: Jan 2016
Location: Cary, NC
Posts: 58
s5511 is an unknown quantity at this point
Re: SPI Write Limitation

We are trying to control the AdaFruit DotStars through the SPI bus, too, except we are using LabVIEW. Which ports on the roboRIO did you guys connect the dotstar to?
__________________


NC Rookie All Star, Rookie Highest Seed 2015
NC THOR Winner 2015
NC Guilford County Winner and Creativity Award 2016
Reply With Quote
  #6   Spotlight this post!  
Unread 21-08-2016, 19:19
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 56
gerthworm has a spectacular aura aboutgerthworm has a spectacular aura about
Re: SPI Write Limitation

Actually, we ended up using both at one point. We started by using the dedicated 10-pin port on the top, then we switched to the port that's on the custom expansion port in the middle.

I'm not familiar with sending bytes in labview. However, I know in java it was just a single initialization parameter to say which SPI port to use. Everything else was the same.

Also as indicated in this thread, we did have to chunk the send data into 128-length bytes to get it to work nicely.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi