Help needed with SimpleLink CC3000

I am a newbie and am working on a home automation project with WiFi and selected CC3000. I have been trying to connect my Adafruit CC3000 Breakout board to Arduino Uno R3 with the following connections:

IRQ - pin 3
VBEN - pin 5
CS - pin 10
MOSI -11
MISO - 12
SCK - 13
Vin - 5V
GND - GND

and tried the buildtest provided in the AdafruitCC3000 library. The program just gets stuck on

Initializing CC3000.......

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed but DI

#define WLAN_SSID "myNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "myPassword"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY WLAN_SEC_WPA2



/**************************************************************************/
/*!
@brief Sets up the HW and the CC3000 module (called automatically
on startup)
*/
/**************************************************************************/
void setup(void)
{
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n"));

  displayDriverMode();
  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
  
  /* Initialise the module */
  Serial.println(F("\nInitialising the CC3000 ..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Unable to initialise the CC3000! Check your wiring?"));
    while(1);
  }

  /* Optional: Update the Mac Address to a known value */
/*
uint8_t macAddress[6] = { 0x08, 0x00, 0x28, 0x01, 0x79, 0xB7 };
if (!cc3000.setMacAddress(macAddress))
{
Serial.println(F("Failed trying to update the MAC address"));
while(1);
}
*/
  
  uint16_t firmware = checkFirmwareVersion();
  if (firmware < 0x113) {
    Serial.println(F("Wrong firmware version!"));
    for(;;);
  }
  
  displayMACAddress();
  
  /* Optional: Get the SSID list (not available in 'tiny' mode) */
#ifndef CC3000_TINY_DRIVER
  listSSIDResults();
#endif
  
  /* Delete any old connection data on the module */
  Serial.println(F("\nDeleting old connection profiles"));
  if (!cc3000.deleteProfiles()) {
    Serial.println(F("Failed!"));
    while(1);
  }

  /* Attempt to connect to an access point */
  char *ssid = WLAN_SSID; /* Max 32 chars */
  Serial.print(F("\nAttempting to connect to ")); Serial.println(ssid);
  
  /* NOTE: Secure connections are not available in 'Tiny' mode! */
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
   
  Serial.println(F("Connected!"));
  
  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }

  /* Display the IP address DNS, Gateway, etc. */
  while (! displayConnectionDetails()) {
    delay(1000);
  }
#ifndef CC3000_TINY_DRIVER
  /* Try looking up www.adafruit.com */
  uint32_t ip = 0;
  Serial.print(F("www.adafruit.com -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName("www.adafruit.com", &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }
  cc3000.printIPdotsRev(ip);
  
  /* Do a quick ping test on adafruit.com */
  Serial.print(F("\n\rPinging ")); cc3000.printIPdotsRev(ip); Serial.print("...");
  uint8_t replies = cc3000.ping(ip, 5);
  Serial.print(replies); Serial.println(F(" replies"));
  if (replies)
    Serial.println(F("Ping successful!"));
#endif

  /* You need to make sure to clean up after yourself or the CC3000 can freak out */
  /* the next time you try to connect ... */
  Serial.println(F("\n\nClosing the connection"));
  cc3000.disconnect();
}

void loop(void)
{
  delay(1000);
}

It's the standard code provided in the library. This is my second breakout board. It just won't initialize. I do not understand. I have done the connection perfectly. I haven't made any changes to the code per say except changing the SSID and password. I am seriously stuck. Cant seem to figure out the problem.

I also tried using pins 2 and 7 instead of 3 and 5. The same problem occurs.

With my first module, I tried the buildtest code. It worked fine. Then it stopped working out of the blue. Removing all the connections and then rewiring it works like 2 out of 10 times. I then thought that it must a problem with firmware. Tried updating the firmware using Arduino Code and bricked it (apparently). I have tried every possible thing. There is a weird problem too. Sometimes when I connect the Arduino to my PC with the CC3000 attached (this is when the module was working), it scanned the networks and tried connecting to the specified SSID in the program. I have Belkin router and then suddenly the WiFi disappears. All the devices connected to the network also lose connection. When I unplug the USB , the Wifi comes back on.

Please help. I have been stuck on these issues for quite some time. I thought i might've bricked my old module and bought a new one. One running buildtest , the module gets stuck and doesn't initialize.

If the device is an SPI device (and it appears to be), pin 10 MUST be set as OUTPUT, regardless of whether you actually use it, or not.

It must be set as OUTPUT BEFORE you try to talk to the SPI device.

The sketch is not complete. What does displayDriverMode() do?

Is the CC3000 the only device on the SPI bus? This is from the AdaFruit site:

On the breakout, be aware that the MISO (data out from module) pin does not go 'high impedance' when CS is driven high. Check the shield for how we use a 74AHC125 to manually tri-state this pin when it's shared with an SD card.

Does that mean in my setup() I should write

pinMode(CS,OUTPUT)

Also, the sketch is incomplete because all the remaining functions just display and print details. Nothing specific happens there.

Also, the sketch is incomplete because all the remaining functions just display and print details. Nothing specific happens there.

What do you mean by "display"? Do you have a display on the Arduino? Or just print to the serial interface? If you have any other device on the SPI bus (a display for example) the quoted text from the AdaFruit site is important for you.

I do not have any other devices on my SPI bus. I do not have a display attached to my Arduino. By display details I mean simply print stuff on the serial monitor.

@pylon I am complete newbie and actually have difficulty figuring out the quoted text. Can you please tell me what does it mean exactly.. ??

I am complete newbie and actually have difficulty figuring out the quoted text. Can you please tell me what does it mean exactly.. ??

It means that the CC3000 is not a fully compliant SPI device but uses a serial hardware interface which is similar to SPI but in details different. This shouldn't be a problem if the device is alone on the SPI bus but you will need additional hardware if you want to add another device to the SPI bus.

How do you power your Arduino while trying to use the module? Just by USB? That doesn't deliver enough power. Connect an external power supply (9V is a good value) to the power plug on your Arduino.