Introduction: Using TI's Cc3000 With AT 1284p

It took me a few extra hours to figure out how to get TI's cc3000 to work with the ATMega 1284p configured to run with the Arduino ISP.

Hopefully this will save the next pour sap from spending the extra time searching the Internet and deciphering the various posts.

Step 1: Getting Started...

First I want to point out that nearly all of what I'm sharing is work from others. I'm simply aggregating the information and showing the modifications I had make to get things working.

The reason I entered into this endeavor is because the ATmega1284p is such a great chip! It fits perfectly between the 328p (Uno) and the 2560P (Mega). It's got tons of memory for things like addressable RGB LEDs (such as Adafruit's excellent NeoPixel strips - http://www.adafruit.com/products/1138), more GPIO and serial ports then 328p and is a fraction of the cost of the 2560P.

I am using the nifty Adafruit cc3000 breakout with built in antenna found here: http://www.adafruit.com/products/1469

This leads me to use the Adafruit library for said breakout but more on that later...

Step 2: Setting Up Your Arduino ISP...

It's important to point out that the Arduino ISP doesn't support the 1284p "out of the box" but fear not! This is super easy and won't hurt a bit.

When searching the internet for 1284p and Arduino you will most likely find quite a few different flavors. There are now a few different boards that have been created using the 1284p. This includes "Goldilocks", Wildfire, among others. I chose to go with the "Mighty 1284p with Optiboot" and so far am pretty happy.

I found this initial setup here: http://maniacbug.wordpress.com/2011/11/27/arduino-...

Following maniacbug's excellent directions you should be able to get the circuit built and the bootloader installed.

Step 3: Connecting the Cc3000...

Few things that are important to note...

There are a variety of pins that can be used for the cc3000. However there appears to be some hard-coding done in the library for the CS pin. If you want to use something other then pin10 (which also happens to be RX1) then you will have to figure that out.

Otherwise the only other pin that is a must is the IRQ pin. This must be connected to one of the three interrupt pins.

As you can see I choose int2 (D2 on the "mighty 1284p with Optiboot" pin mapping) for my IRQ pin, D5 for my enable pin (also called VBAT), and D10 for my CS pin.

Again, these pins may vary if you use a different bootloader with a different pin mapping.


Step 4: Modifying the Adafruit Cc3000 Library...

When I was trying to figure this out I found what finally solved my issue in this post:
http://forum.freetronics.com/viewtopic.php?f=36&t=...

I say finally because just making this change to the Adafruit_CC3000.cpp file did NOT completely solve my issue.

It got things mostly working until I realized that the change listed in the post was for the Goldilocks bootloader and did not reflect the interrupt pin numbers for the "mighty 1284p with Optiboot". As you can see below between the Start support of 1284p and End support for 1284p, the pin number is followed by the interrupt number.

My actual edits to the Adafruit_CC3000.cpp file look like this:


#include "Adafruit_CC3000.h"
#include "ccspi.h"
#include "utility/cc3000_common.h"
#include "utility/evnt_handler.h"
#include "utility/hci.h"
#include "utility/netapp.h"
#include "utility/nvmem.h"
#include "utility/security.h"
#include "utility/socket.h"
#include "utility/wlan.h"
#include "utility/debug.h"
#include "utility/sntp.h"

uint8_t g_csPin, g_irqPin, g_vbatPin, g_IRQnum, g_SPIspeed;

static const uint8_t dreqinttable[] = {
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined (__AVR_ATmega328__) || defined(__AVR_ATmega8__)
2, 0,
3, 1,

/* start support for 1284p */

#elif defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)|| defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644PA__)
2, 2,
11, 1,
10, 0,

/* end support for 1284p */


#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
2, 0,
3, 1,
21, 2,
20, 3,
19, 4,
18, 5,
#elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY)
5, 0,
6, 1,
7, 2,
8, 3,
#elif defined(__AVR_AT90USB1286__) && defined(CORE_TEENSY)
0, 0,
1, 1,
2, 2,
3, 3,
36, 4,
37, 5,
18, 6,
19, 7,
#elif defined(__arm__) && defined(CORE_TEENSY)
0, 0,
1, 1,
2, 2,
3, 3,
4, 4,
5, 5,
6, 6,
7, 7,
8, 8,
9, 9,
10, 10,
11, 11,
12, 12,
13, 13,
14, 14,
15, 15,
16, 16,
17, 17,
18, 18,
19, 19,
20, 20,
21, 21,
22, 22,
23, 23,
24, 24,
25, 25,
26, 26,
27, 27,
28, 28,
29, 29,
30, 30,
31, 31,
32, 32,
33, 33,
#elif defined(__AVR_ATmega32U4__)
7, 4,
3, 0,
2, 1,
0, 2,
1, 3,
#endif
};
/***********************/

Step 5: Configuring Buildtest Example...

This is the easy part!

Open the buildtest.ino example and adjust the following lines to look like mine:

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ 2 // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT 4
#define ADAFRUIT_CC3000_CS 10

And presto! You're done. Your cc3000 will now work as advertised on the Mighty1284p with Optiboot.