Baines, I have the 1284 working simultaneously with ethernet, SD, RFM12 radio, and the ColorLCD shield - and which all use the SPI port pins D11..D13. I use a similar pinout to the Bobuino, but slightly different. CS is probably not your problem. Try this - from the issues page I cooked up for the 1284.
See what I call "Fix #1" in the upper part, and how it apples to Ethernet in the lower part.
1. Lack of 1284(P) Support in Arduino Libraries
For some reason, Arduino central command didn't include support for ATmega1284(P) chips in the libraries that come packaged with the Arduino IDE. These libraries can be seen by opening the IDE "File > Examples" menu, and include: EEPROM, Ethernet, LiquidCrystal, SD, Servo, on and on.
The fix for this problem is "relatively" simple, because the 1284 and 1284P chips have a similar port assignment to the ATmega2560 and 1280 chips. So, the procedure is:
find the specific Arduino library in the IDE directory, eg in path:
".\arduino-1.0.5-windows\arduino-1.0.5\libraries\Ethernet".
look through the source files in the directory, and also any subdirectories, for lines such as:
#if defined(AVR_ATmega1280) || defined(AVR_ATmega2560)
inline static void initSS() { DDRB |= _BV(4); };
inline static void setSS() { PORTB &= ~_BV(4); };
inline static void resetSS() { PORTB |= _BV(4); };
and simply add the 1284P extension (call this [glow=yellow,2,300]Fix #1[/glow]):
#if defined(AVR_ATmega1280) || defined(AVR_ATmega2560) || defined(AVR_ATmega1284P)
inline static void initSS() { DDRB |= _BV(4); };
inline static void setSS() { PORTB &= ~_BV(4); };
inline static void resetSS() { PORTB |= _BV(4); };
So, anytime one of the Arduino IDE libraries is used, or a 3rd party library is installed for use with the 1284(P) chips, all of the .cpp and .h source files in the library should be immediately examined to see whether they need the change described here.
Furthermore,
10. Misc IDE Files and Libraries Checked for ATmega1284(P) Support
The following files in Arduino IDE version 1.0.5 have been checked for ATmega1284(P) support. There may also be some support in earlier versions of the IDE, but those are not dealt with here. These files are in the ArduinoCore ".\hardware\arduino\cores\arduino" subdirectory in the Arduino IDE.
- "Arduino.h" = ok ... since 1284(P) support has been included in IDE v1.0.5.
- "Client.h", "IPAddress.h", and "IPAddress.cpp" files = ok ... no direct references to cpu types.
NOTE - the "Arduino.h" file indicated above has support for several different ATmega1284(P) and ATmega644(P) chips, so consult that file for a more comprehensive version of Fix #1.
Also, the very end of "Arduino.h" has a < #include "pins_arduino.h" > statement, so it will automatically handle different board variants with different pinouts.
We also checked the following standard Arduino libraries, found in IDE subdirectory "\libraries" :
- SPI library = ok ... since SPI.cpp references only "pins_arduino.h", the SPI pin callouts are taken
care of in the specific 1284 variant being used.
- EEPROM library = ok ... no cpu references.
- SoftwareSerial library = ok ... no cpu references.
- Wire library = ok ... references only "Arduino.h" and "pins_arduino.h".
[color=red][b]
- Ethernet library = needs fixing ... as of IDE v.1.0.5, file "w5100.h" still requires
Fix #1 listed above.
[/b][/color]
- Servo library = needs fixing ... file "Servo.h" requires Fix #1 listed above
- SD library = needs fixing ... both "S2dCard.h" and "Sd2PinMap.h" require Fix #1 listed
above, plus the latter file requires more serious attention.
We've also checked the following 3rd party libraries for ATmega1284P support:
-
Xively library = ok.
-
HttpClient library (used with Xively) = ok ... references "Arduino.h", "Client.h", and "IPAddress.h",
which are all ok, per checks listed above.
-
Twitter library = ok ... references "Ethernet.h" and "EthernetDNS.h", which are ok, as long
as "w5100.h" is fixed as indicated above.
-
Time library (used by Twitter) = ok.
-
Sha library = ok.
-
LowPower Labs RF12 library (used with Hope RFM12 modules) = works ... includes
Sanguino/644 support (but totally NFG for Bobuino variant).
-
Mikem RFM22 library (used with Hope RFM12 modules).
-
maniacbug nRF2401 library = ok ... uses only references to "Arduino.h" and "SPI.h".
-
ElecFreaks ColorLCD library = needs fixing ... file "ColorLCDShield.cpp" requires Fix #1
listed above (note - this fix also applies to the Sparkfu ColorLCDShield library).
-
Jeelib library (used with Hope RFM12 modules) = has so many bugs we don't use it.
I included all the other stuff here, just to show you there are many other issues with trying to use the 1284.