It’s my first time posting on this forum so bare with me. This is my current hardware setup:
Arduino Uno
Sparkfun’s CC3000 Wifi Breakout
Cheap SD card breakout from ebay
Both devices are driven using SPI and are wired correctly. When running an the CardInfo sketch with just the SD card on the bus, the information is read perfectly. When running the CC3000 example code (Webclient) with just cc3000 on the bus, the information is transmitted perfectly. As soon as a plug the CC3000 and the SD card to the SPI bus with chip selects 4 and 6 respectively, I am not able to run the CardInfo sketch. I get an “SD card initialization failed!” error.
What’s even weirder…is that the setup() function keeps repeating. Here is the example output:
Initializing SD card…initialization failed. Things to check:
is a card is inserted?
Is your wiring correct?
did you change the chipSelect pin to match your shield or module?
initialization failed. Things to check:
is a card is inserted?
Is your wiring correct?
did you change the chipSelect pin to match your shield or module?
initialization failed. Things to check:
is a card is inserted?
Is your wiring correct?
did you change the chipSelect pin to match your shield or module?
initialization failed. Things to check:
is a card is inserted?
Is your wiring correct?
did you change the chipSelect pin to match your shield or module?
And here is the output when just the SD card is plugged in:
Files found on the card (name, date and size in bytes):
SYSTEM~1/ 2014-10-13 17:49:58
INDEXE~1 2014-10-13 17:49:58 76
I’ve tried several things including:
Setting the chipselects of both devices to OUTPUTS and HIGH at the beginning of the sketch
Adding pull-up resistors to each chip select
Does anyone know what could be happening here? My next assumption is an overcurrent condition that triggers a reset when both devices are plugged in. NOTE: both devices are receiving power from the same 5V output from the Uno, which is powered through USB.
There are various hardware setting for SPI: data rate, clock edge, bit order... Each library has to re-set those parameters each time they want to access the hardware or they have to all use the same parameters. Many just set them in .begin() and assume they stay set forever. Fortunately you have the library source code so you can examine the code and fix it as needed.
Thanks for your reply! However, I am only running one at a time therefore the SPI settings wouldnt change in between.
Here is a breakdown of what I'm doing:
Plug in SD card and run CardInfo sketch example. Everything runs smoothly.
Unplug SD card. Plug in CC3000 Breakout board. Run Webclient sketch. Everything runs smoothly.
Re-plug in SD card shield so that both SD card shield and Wifi breakout are on the SPI bus.
Try to run CardInfo sketch (same as part 1 - nothing to do with Wifi) - sketch fails and/or keeps repeating.
I've pressed the reset switch as well and sometimes it will output something different on the Serial window for example the initialization will pass but the volume definitions cannot be fetched etc.
Sounds like a hardware problem. One of the devices (probably the CC3000) is not properly getting off the SPI bus when its SlaveSelect (CS) pin is HIGH.
Any known ways to combat this issue given the hardware problem? And I think the SD card might be the culprit because it shows the same behavior with the ethernet shield, which is why I purchased a separate SD shield. But I'm not sure how to move forward from here...
Still stuck...Tried unplugging the CS, EN and IRQ pins for the CC3000 breakout and still did not allow the SD card to work correctly. The only way that the SD card works is by unplugging the CC3000 entirely.
It appears the CC3000 uses interrupts, and uses the SPI bus in an interrupt. This will cause problems with the CC3000 and the SD card. If the SD card is using the SPI bus (SD slave select LOW) and the CC3000 triggers an interrupt, that causes problems for both devices.
IDE v1.5.8 BETA is supposed to be able to allow both devices to work together, but I have not tested it yet. The Adafruit library apparently has the mods for IDE v1.5.8 included.
I see what you mean, and that was my assumption also when I unplugged the IRQ wire from the Arduino entirely. The IRQ wire that goes from the CC3000 is the interrupt wire; with that unplugged, how would it still alter the SD card operation?
That depends on how you have the CC3000 CS (Slave Select) pin set. If you do not set the CC3000 SS as OUTPUT and HIGH, it will garbage up the SPI bus during the SD card init.
I am not only setting the CS of the Wifi to OUTPUT and HIGH in software, but also added an external pull up resistor to the CS pin on the CC3000 to no avail.
Since I do not have access to a scope to see exactly what is corrupting the bus, I removed one wire at a time from the CC3000, and found that nothing worked except removing the power entirely. Really not sure where to go from here...