So I got my brandy new Arduino Mega 2560 in the mail. It has 256KiB of program memory (8x the memory of a standard Arduino!)
As I mentioned in my last post, the standard Arduino only has 32KiB of program memory, and with all of the networking features I want compiled into the library I’m using, I was already at 33KiB. But now with a spacious 256KiB (What will I ever do with it all!) I can add in features until my heart’s content! (DNS and DHCP oh my!) Other than the extra memory (and extra I/O pins) It is identical to the regular Arduinos. Or so I thought… (cue the misery.)
Getting a blinking LED sketch (Arduino speak for program) running on it from the Arduino IDE was easy enough. But replicating it inside my Code::Blocks setup was not so easy. It took further modification of my command line scripts for which there was little to no documentation to base it off of. After lots of groping around in the dark, trial and error, and some guess work, I got it there. Though the auto-reset was not working, so I have to time a physical reset of the board with the compile button in the IDE to get the programs to upload. *annoying*. This took a few hours… but it gets worse.
Then began the real pain. You see, the trouble starts with the fact that the wonderful WiFi board that I use (the WiShield, made by AsyncLabs) is no longer in production. In fact, in March of this year, AsyncLabs shuttered their little studio completely. Which is a real bummer because they are the ONLY mature, drop-in WiFi solution for Arduino 🙁
With AsyncLabs out of the picture, development on its library and support in its forums has all but ceased. With the Mega2560 being a relatively new board, its fair to say that support will never be added for it in the WiShield’s code. Now you might ask, but Adam! You said the Mega was pretty much identical to other Arduinos! Why would support need to be added at all! And it’s because it’s NOT identical. There is a small difference that turned out to be vitally important.
You see the Arduino’s are based on an AVR type chip manufactured by Atmel. Atmel makes a variety of these chips under the ATmega line.
These ATmega chips provide a nice little piece of hardware/software functionality called SPI or Serial Protocol Interface. I won’t go into the details, but it’s critical to the functioning of the WiShield.
This is where the problem lies. Arduino’s based on the ATmega168 or the ATmega328, have their SPI pins on 11, 12, 13.
But Arduino’s based on the ATmega1280 or the ATmega2560, have their SPI pins on 51, 52, 53.