0

CC3000 SPI with Sparkfun Fio V3
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CC3000 SPI with Sparkfun Fio V3

by Enkryptikon on Fri Nov 08, 2013 1:57 pm

I'm trying to get the CC3000 working on my Sparkfun Fio V3. But it's hanging on init (wlan.cpp/wlan_start/ in one of the whiletSLInformation.ReadWlanInterrupPin()). With a Arduino UNO it's working perfectly, so it's not the board. Is there anybody with the same problem? And may be a solution.

I found out certain weird little aspects about the SPI on the fio v3, btw, trying to solve it myself. While in the hardware/SF32u4_boards-master/variants/promicro/pins_arduino.h the setup is

SS=17
MOSI=16
MISO=14
SCK=15

on the board layout/pdf it's

SS=14
MISO=17

I have put the WLAN_IRQ on 7 and WLAN_ENABLE on 8, for I use 2 and 3 for I2C, but even if I set it up on 2/3 it won't work.
I tried the Adafruit-Library as well as the ArduinoCC3000Test files. With every imaginable cableing. Not working. We tried an other Fio V3 with the same result. So it's not the Board, it's not the Fio V3. Maybe anybody has some experience with SPI on the Sparkfun, or is it a power problem with the CC3000? We checked everything we could.

I'm really out of ideas at the moment. Can anybody help? Please.
Maybe it's something stupidly simple that we don't see.

using
https://github.com/sparkfun/SF32u4_boards
https://github.com/adafruit/Adafruit_CC3000_Library / buildtest

Hello, CC3000!

RX Buffer : 131 bytes
TX Buffer : 131 bytes
Free RAM: 1237

Initialising the CC3000 ...
<stopped>

As well as
https://github.com/cmagagna/ArduinoCC3000Test

With always the same result: hung.
Enkryptikon
 
Posts: 6
Joined: Fri Nov 08, 2013 1:41 pm

Re: CC3000 SPI with Sparkfun Fio V3

by adafruit_support_mike on Fri Nov 08, 2013 7:40 pm

Best guess is that it's hanging during the asynchronous initialization process.

Start by adding:

Code: Select all | TOGGLE FULL SIZE
#define DEBUG_MODE 1

and getting the diagnostic output to see if that gives you more information about what's failing. If necessary, hop into the library and use the DEBUGPRINTF() macro to add new print routines on either side of operations that could be failing.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 39365
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC3000 SPI with Sparkfun Fio V3

by Enkryptikon on Sun Nov 10, 2013 8:23 am

It's not as easy like that. First of all a #define DEBUG_MODE 1 doesn't give me the debug outputs. Didn't find out how to activate the debug output but nevermind. Something weird with that module. Not important.

I put my own output in and found out that it's working until it hits the

SimpleLinkWaitEvent(HCI_CMND_SIMPLE_LINK_START, 0);

line at the end of wlan.cpp/wlan_start. Which means the ReadWlanInterruptPin was okay.
Still following the rabbit hole.

Then I followed it until the evnt_handler.cpp where I'm still working on it. Googling gets me some issues with the CC3000 on the Ti E2E forums, where they are trying to troubleshoot some SPI issues. There are more people out there that have problems with that, so hopefully I'm not totally alone. Sadly those people don't use an Arduino/Sparkfun Fio V3 as far as I can see. My guess it's some issue with the SPI specifications. I'm currently not into this, so I hope I might get some more help, before I have to reverse engineer the whole stuff.

I also found nobody who has published a working SPI with the Fio V3. Maybe it's an issue there? As I said, the module is working fine on an Arduino UNO. Which is 5V board, not 3.3V. We tried to drive the board with 5V and connect it over a logic converter with the Fio V3, which didn't work either. So it's probably not the voltage.

I have no other module working with SPI on the Sparkfun Fio V3, so I can't rule out if it's only an issue with the CC3000 firmware or what.

EDIT: okay, Debug Mode
Hello, CC3000!

MISO 17
MOSI 16
SS 14
SCK 15
ADAFRUIT_CC3000_IRQ 7
ADAFRUIT_CC3000_VBAT 8
ADAFRUIT_CC3000_CS 14
RX Buffer : 131 bytes
TX Buffer : 131 bytes
Free RAM: 1685

Initialising the CC3000 ...
CC3000: init_spi
CC3000: Finished init_spi
init
start
CC3000: SpiOpen CC3000: WlanInterruptEnable.
CC3000: Finished SpiOpen
CC3000: ReadWlanInterruptPin - 001
CC3000: WriteWlanPin - 001
CC3000: ReadWlanInterruptPin - 001
repeating last line 45 times
CC3000: ReadWlanInterruptPin - 001
CC3000 CC3000: Entering SPI_IRQ
CC3000: Leaving SPI_IRQ
: ReadWlanInterruptPin - 000
SimpleLink start
CC3000: SpiWrite
CC3000: SpiWriteFirst
CC3000: SpiWriteDataSynchronous Start
01 00 05 00
CC3000: SpiWriteDataSynchronous End
CC3000: SpiWriteDataSynchronous Start
00 01 00 40 01 00
CC3000: SpiWriteDataSynchronous End
CC3000: Entering SPI_IRQ
CC3000: SpiReadHeader
CC3000: SpiReadDataSynchronous
FF FF FF FF FF FF FF FF FF FF
CC3000: SpiContReadOperation
CC3000: SpiReadDataCont
CC3000: SpiTriggerRxProcessing
CC3000: SpiPauseSpi
CC3000: Leaving SPI_IRQ
CC3000: SpiResumeSpi
CC3000: Entering SPI_IRQ
CC3000: SpiReadHeader
CC3000: SpiReadDataSynchronous

…then repeating "FF FF FF…" SpiContReadOperation… to end forever
Enkryptikon
 
Posts: 6
Joined: Fri Nov 08, 2013 1:41 pm

Re: CC3000 SPI with Sparkfun Fio V3

by adafruit_support_mike on Mon Nov 11, 2013 11:06 pm

Hmm.. it looks like the trouble is happening in the function `SpiReadDataCont()`, but let's see what the read loop is actually getting for parameters. Try modifying `SpiReadDataSynchronous()` in file 'ccspi.cpp' around line 415 like so:

Code: Select all | TOGGLE FULL SIZE
void SpiReadDataSynchronous(unsigned char *data, unsigned short size)
{
  int i = 0;
 
  DEBUGPRINT_F("\tCC3000: SpiReadDataSynchronous\n\r");
  DEBUGPRINT_F("size=");
  DEBUGPRINT_DEC(size);

  SPI.setDataMode(SPI_MODE1);
  for (i = 0; i < size; i ++)
  {
    data[i] = SPI.transfer(0x03);
    DEBUGPRINT_F("  ");
    DEBUGPRINT_DEC(i);
    DEBUGPRINT_F("  ");
    DEBUGPRINT_HEX(data[i]);
  }
  DEBUGPRINT_F("\n\r");
}
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 39365
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC3000 SPI with Sparkfun Fio V3

by Enkryptikon on Thu Nov 14, 2013 6:02 am

Yeah, did that:

Code: Select all | TOGGLE FULL SIZE
size=010  000  FF  001  FF  002  FF  003  FF  004  FF  005  FF  006  FF  007  FF  008  FF  009  FF
   CC3000: SpiContReadOperation
   CC3000: SpiReadDataCont
   CC3000: SpiTriggerRxProcessing
   CC3000: SpiPauseSpi
   CC3000: Leaving SPI_IRQ
   CC3000: SpiResumeSpi
   CC3000: Entering SPI_IRQ
   CC3000: SpiReadHeader
   CC3000: SpiReadDataSynchronous


Still I don't see what's the matter. The SPI seems to pull FF all the time and no real data. Like either the line isn't moving low/high or there's some problem with the timing. I can't say which it is. I checked the problem the folks at the IT forum were disputing but it seems to be a different problem. There is indeed talk about slightly different ways to implement SPI. My guess is, that's the point to look at. But on the other hand a 32U4 is not that freakish.

I'm an advanced programmer, but I am just a newbie on those Arduinos. So I have no experience in programming SPI and I'm fighting hard to find out what's happening here, I have to admit. Thank you for helping me a bit. I'll try everything to make it work. It's one of those crucial steps in my project where I can't go any further without solving it. And the CC3000 is indeed the finest Wifi shield there is. So I'm not ready to give up and turn to one of those serial devices.

I may point out there are a few differences between the 32U4 and the usual Arduino processor. First of all it's 8 MHz instead of 16 MHz. That's why it could be some issue with the timing. Then there might be some pullups or something that change the validity of the data. I discovered, using the Humidity Sensor HDT11 that the code from Adafruit results in 0.0/0.0 values on my Fio V3, where testcode from an other source was producing correct results. And last but not least it's 3.3V instead of 5V. On a standard Arduino I had no problems.

Of course that has nothing to do with SPI for it's just a single-line data transmission, but if the level or timing in that device fails from the same effect that causes trouble with the SPI transmission, it could be the point? Or is that guess totally nonsense?

For timing issues I would suspect the values would dance around random values between 0 and 1. That's why I think -at the moment- it's something different. It doesn't make sense that with timing the SPI pull would always produce ones -> FF.

But that's the reason I think the problem is absolutely solvable. I just have no idea how. Like code for the HDT11 shows weird effects too, which is also a serial communication. There seem to be other ways to pull that communication that work.
Enkryptikon
 
Posts: 6
Joined: Fri Nov 08, 2013 1:41 pm

Re: CC3000 SPI with Sparkfun Fio V3

by adafruit_support_mike on Thu Nov 14, 2013 5:21 pm

Okay, that traces back through the functions `SpiReadDataCont()` and `SSIContReadOperation()` to the interrupt handler `SPI_IRQ()`.

Does the value for the loop index increase, or does it start over from zero every time?
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 39365
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC3000 SPI with Sparkfun Fio V3

by Enkryptikon on Thu Nov 14, 2013 7:45 pm

Starting over from Zero every time.

Code: Select all | TOGGLE FULL SIZE
size=010  000  FF  001  FF  002  FF  003  FF  004  FF  005  FF  006  FF  007  FF  008  FF  009  FF
   CC3000: SpiContReadOperation
   CC3000: SpiReadDataCont
   CC3000: SpiTriggerRxProcessing
   CC3000: SpiPauseSpi
   CC3000: Leaving SPI_IRQ
   CC3000: SpiResumeSpi
   CC3000: Entering SPI_IRQ
   CC3000: SpiReadHeader
   CC3000: SpiReadDataSynchronous
size=010  000  FF  001  FF  002  FF  003  FF  004  FF  005  FF  006  FF  007  FF  008  FF  009  FF
   CC3000: SpiContReadOperation
   CC3000: SpiReadDataCont
   CC3000: SpiTriggerRxProcessing
   CC3000: SpiPauseSpi
   CC3000: Leaving SPI_IRQ
   CC3000: SpiResumeSpi
   CC3000: Entering SPI_IRQ
   CC3000: SpiReadHeader
   CC3000: SpiReadDataSynchronous
size=010  000  FF  001  FF  002  FF  003  FF  004  FF  005  FF  006  FF  007  FF  008  FF  009  FF
   CC3000: SpiContReadOperation
   CC3000: SpiReadDataCont
   CC3000: SpiTriggerRxProcessing
   CC3000: SpiPauseSpi
   CC3000: Leaving SPI_IRQ
   CC3000: SpiResumeSpi
   CC3000: Entering SPI_IRQ
   CC3000: SpiReadHeader
   CC3000: SpiReadDataSynchronous

…and so on.

Also, the IRQ Pins on the Atmega32U4 are defined in Adafreuit_CC3000.cpp as
Code: Select all | TOGGLE FULL SIZE
#elif  defined(__AVR_ATmega32U4__)
  7, 4,
  3, 0,
  2, 1,
  0, 2,
  1, 3,
#endif

I'm using Pin 7, so, IRQ 4 for IRQ from CC3000. I checked it against the ATmega32U4, where Pin 0,1,2,3,7 are correct. So it's an IRQ pin, as far as I can see.

Reference: Atmega32U4 manual, page 3:
Pin 18=PD0=INT0
Pin 19=PD1=INT1
Pin 20=PD2=INT2
Pin 21=PD3=INT3
Pin 1=PE6=INT6

"INT6" should be correct with "irq4" in Adafruit_CC3000.cpp (see reference above). I tested it to change the vector to 6, which was causing the program to hang much earlier. So I say the IRQ is working fine. It's also correct that Pin 1 is connected to Pin7 on the Arduino. (see as reference "Fio-V30.sch"). Cables are okay. Twice and triple checked. No error here.

Tested with Pin 2 and Pin 3, same result. If the Interrupts are assigned correctly I can't say at the moment. Looking a bit weird, if I may say in my humble opinion. Do you know if that's correct? I'm just saying… The Interrupt numbers look a bit garbled. On other Arduinos it's 0-0 1-1 2-2- 3-3 at least. here it's 0-2 1-3 2-1 3-0 7-4. Funny. That's correct, yes?

I checked that against hardware/SF32u4_boards-master/variants/promicro/pins_arduino.h which is looking okayish, just about INT6<->4 I have no idea. And I'm not sure if that's really corresponding with the ATmega32U4 manual. This "4"… that isn't looking right. Manual Page 87 11.0.3 all the IRQ-masks are showing bit 6. Why is it a 4 here in the Adafruit code? Can you explain? Sadly, as said above, changing it to 6 doesn't help. Anyway.

Additionally I will check if for all pins pinMode(pin, INPUT); digitalWrite(pin, LOW); is needed to maybe remove the internal pull-up resistor. I don't know if that is done correctly in the code or if the 32U4 is doing is somewhat different than the usual processor.

Maybe I try to test hardware interrupting with an external button or something? Hm. I find it a bit irritating, that the pins_arduino.h say one thing, the Adafreuit_CC3000.cpp say an other and the 32U4 manual is telling me there is nothing garbled at all about the interrupts. WTF? I can't see the light. Please call the Blues Brothers.
Enkryptikon
 
Posts: 6
Joined: Fri Nov 08, 2013 1:41 pm

Re: CC3000 SPI with Sparkfun Fio V3

by Enkryptikon on Sun Nov 17, 2013 5:07 pm

The IRQs are correct. I tested D2->IRQ1, D3->IRQ0, D7->IRQ4.
Check correct OUTPUT for pins SS, SCK, MOSI in SPI.cpp/SPIClass::begin()

The Leonardo has the same problem, no connection to the CC3000.
Enkryptikon
 
Posts: 6
Joined: Fri Nov 08, 2013 1:41 pm

Re: CC3000 SPI with Sparkfun Fio V3

by ranthor on Sun Dec 08, 2013 11:05 am

I tried and got it working. Here is how:

1) The board definitions for the Fio v3 seem to be wrong.
  • D14 is routed to the SS pin on the ATmega32u4 (PB0) and is shared with the RX LED
  • D15 is routed to the SCLK pin on the ATmega32u4 (PB1)
  • D16 is routed to the MOSI pin on the ATmega32u4 (PB2)
  • D17 is routed to the MISO pin on the ATmega32u4 (PB3)

A fork of the SFE board definitions with fixed pin assignments can be found here:
https://github.com/ranthor/SF32u4_boards

2) Pin assignment and connection:
  • D7 to IRQ
  • D8 to VBAT
  • D9 to CS (yes, D9, not D14 aka the SS pin, more on that later)
  • D15 to SCLK
  • D16 to MOSI
  • D17 to MISO
  • 3v3 to 3v3 (yes, not to VIN, more on that later)
  • GND to GND

3) Notes:
  • CS could be connected to D14 as well, but its use as the RX LED pin interferes with the operation of the CC3000 and other SPI hardware. The Arduino Leonardo does the same thing, but doesn't even break this pin out for user applications, probably for exactly this reason.
  • The ATmega32u4 disables hardware SPI whenever its SS pin is set to anything but an output. Since the corresponding pin D14 is used for the RX LED, this should not be an issue, but keep it in mind when fiddling with that specific pin.
  • VIN can not be used to power the CC3000 breakout because from 3.3v, the on-board regulator seems to drop the board voltage too low for the board to function properly. Using the 3v3 pin on the breakout bypasses the regulator and makes the board work like a charm.
ranthor
 
Posts: 1
Joined: Sun Dec 08, 2013 10:56 am

Re: CC3000 SPI with Sparkfun Fio V3

by Enkryptikon on Sun Dec 08, 2013 12:13 pm

Great. Working like a charm. I suspected that there were some heavy issues with the arduino_pin.h
Working on Pin 14 CS without any issues on my board, by the way. But the LED issue on Pin 14 might indeed lead to problems. I keep it on 9 now.

Please someone contact developers to update the official files.
Enkryptikon
 
Posts: 6
Joined: Fri Nov 08, 2013 1:41 pm

Re: CC3000 SPI with Sparkfun Fio V3

by bustotufunk on Fri Jun 26, 2015 6:45 pm

Hi. How did you set the Debug mode?

bustotufunk
 
Posts: 102
Joined: Mon Feb 03, 2014 4:16 pm

Re: CC3000 SPI with Sparkfun Fio V3

by bustotufunk on Fri Jun 26, 2015 7:25 pm

Nevermind. Figured it out. Perhaps this will help the next person:

In debug.h change this:
Code: Select all | TOGGLE FULL SIZE
#define DEBUG_MODE                      (0)


To this:
Code: Select all | TOGGLE FULL SIZE
#define DEBUG_MODE                      (1)


I don't know how I missed that one.

bustotufunk
 
Posts: 102
Joined: Mon Feb 03, 2014 4:16 pm

Re: CC3000 SPI with Sparkfun Fio V3

by usamasaeed on Mon Oct 31, 2016 12:36 pm

Hy Enkryptikon, this is the same problem im having with my project. Im using arduino uno with cc3000 wifi shield, my code stucks on "initialising the cc3000..." when i set the debug mode to (1), i saw values like yours. Can you help me a bit?

usamasaeed
 
Posts: 7
Joined: Sun Oct 30, 2016 11:58 am

Please be positive and constructive with your questions and comments.