Trying to get CC3000 and sd shield to work together over SPI

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
toegap
 
Posts: 14
Joined: Sun Aug 18, 2013 3:23 am

Trying to get CC3000 and sd shield to work together over SPI

Post by toegap »

Hello,

I am trying to get the sd shield, cc3000 breakout board, and the Arduino to work together over SPI. I am using the sdfat library, select pin has been routed to pin 4, and the speed set to SPI_FULL_SPEED. I can init the card prior to going into the cc3000 wifi startup code. However when I try to open the file the code/arduino stalls. I tried placing SpiPauseSpi(); and SpiResumeSpi(); around the file open, read, close block, but it seems rather slow. Are there any pointers you can give me? Is there something else I should be doing?

Thanks

User avatar
technobly
 
Posts: 118
Joined: Mon Oct 31, 2011 11:06 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by technobly »

Toegap, please post your code and I'll try to work this out with you. I need to do similar things, but my first issue is read speed. Without read speed, there is no need to have 2GB of SD card ;-) Even so I need to start poking sticks at all the problems.
Last edited by technobly on Thu Aug 22, 2013 11:05 am, edited 1 time in total.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by adafruit_support_rick »

toegap wrote:However when I try to open the file the code/arduino stalls.
That sounds a lot like a memory issue. You probably want to have a look at our Arduino Memories tutorial:
http://learn.adafruit.com/memories-of-an-arduino

toegap
 
Posts: 14
Joined: Sun Aug 18, 2013 3:23 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by toegap »

In this case it is not a memory issue, because I am using an Arduino Mega 1280. I have changed the select pin to 53 your code. Any other ideas? Perhaps you could update the library to have an example of this(using another device via SPI at the same the cc3000 is in use)? I think many people would benefit from it.

Fightcube, I will post the code when I get a chance, but don't have much to it. I am just trying to open a file, read into a buffer, write the buffer to a socket.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by adafruit_support_rick »

toegap wrote:Any other ideas?
Yuck. This is a problem with SD. We have the same issue with the 2.8" TFT. SD sets up the SPI control register once when you call begin(), and expects it to be correct forever after. Well-behaved SPI drivers should save SPCR, reconfigure it for their own purposes, and then restore SPCR on the way out.

ccspi in the CC3000 library does this, but perhaps there's a hole in the logic. I'm thinking it may be in the initialization.

In what order are you doing things? Are you calling SD.begin before cc3000.begin()? If so, try doing it the other way - call cc3000.begin() first.

toegap
 
Posts: 14
Joined: Sun Aug 18, 2013 3:23 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by toegap »

Rick,

You are right about the SPCR. That needs be different for each of the libraries. If both libraries are set to SPI_CLOCK_DIV2, the only difference is that cc3000 uses SPI.setDataMode(SPI_MODE1) while sdfat(sd card) uses SPI.setDataMode(SPI_MODE0). Both of these effect the state of the SPCR variable. So you need to toggle the SPCR back and forth when you are using these libraries. I know you said the cc3000 library behaves nicely in that it saves the state before and after spi operations, but I saw at least one hole in that, on the init function.

So, I got the libraries working together, however it is still slow, mostly due to packet write limitation of (240 bytes - header) and also due to complexity of the interrupt routines(not to mention management of the additional buffer). If it would be possible to update this library to poll, I think it would help speed things up.

Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by adafruit_support_rick »

What exactly did you have to do to make the libraries play together nicely?

I'm not sure I understand how polling would speed it up. Can you elaborate?

brianwong3
 
Posts: 4
Joined: Tue Sep 17, 2013 9:19 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by brianwong3 »

toegap, I am having the same issues but with the PN532 and the CC3000. Mind explaining the solution?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by adafruit_support_rick »

You're using the PN532 in SPI mode?

brianwong3
 
Posts: 4
Joined: Tue Sep 17, 2013 9:19 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by brianwong3 »

Yeap....Rick, any ideas?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by adafruit_support_rick »

Well, the shield is really designed to use I2C - if you can switch to that, you shouldn't have any trouble at all.

Otherwise, what pins have you configured for MOSI, MISO, SCK, and CS?

brianwong3
 
Posts: 4
Joined: Tue Sep 17, 2013 9:19 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by brianwong3 »

tried to debug..got sick of it and decided to move to I2C...

problem now is the CC3000 library is killing the RAM...

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trying to get CC3000 and sd shield to work together over SPI

Post by adafruit_support_rick »

The CC3000 library is not hugely memory hungry. Perhaps you can save some space in your sketch. Have a look at our Memories tutorial for some tips:
http://learn.adafruit.com/memories-of-an-arduino

kanderek
 
Posts: 4
Joined: Mon Nov 25, 2013 3:34 pm

Re: Trying to get CC3000 and sd shield to work together over

Post by kanderek »

I have a very similar challenge as toegap. (I'm actually a bit disappointed that he didn't share his breakthrough.) Anyways, I'm trying to toggle select between the CC3000 breakout board and the adafruit SD breakout board. I have validated that both work alone but I'm not clear how to get switch data control via the chip select based on the libraries as they are. I've attached my code which is based on the webclient example. All help is appreciated.
webClientRFID.txt
(9.84 KiB) Downloaded 63 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trying to get CC3000 and sd shield to work together over

Post by adafruit_support_rick »

Where have you routed the chip selects for each breakout?

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”