Go Down

Topic: Ethershield ENC28J60 connection to MEGA1280 or 2560 (Read 3725 times) previous topic - next topic


Hello, sorry if this is a re-post.
I have been using an Ethershield ENC28J60 as a web server with arduino 2009, also using it as an NTP client. I soon found out that ATMEGA328  ran out of both FLASH and RAM space. Therefore i decided to switch to an ATMEGA1280 board. Unfortunatelly just plugging the Ethershield board on the Mega Board will not do the trick, so here's the changes that have to be done in order to have it working as i did:
The boards must NOT be plugged together. Instead connect them with wires as follows:
Ethershield GND -> MEGA1280 GND
Ethershield 5V -> MEGA1280 5V
Ethershield Reset -> MEGA1280 Reset (This is pin 5 of ICSP connector)
Ethershield 10 -> MEGA1280 53 (SS)
Ethershield 11 -> MEGA1280 51 (MOSI)
Ethershield 12 -> MEGA1280 50 (MISO)
Ethershield 13 -> MEGA1280 52 (SCK)
Changes in file "enc28j60.c" in EtherShield Libraries folder:

replace these lines:
const static uint8_t SS   = 10;
const static uint8_t MOSI = 11;
const static uint8_t MISO = 12;
const static uint8_t SCK  = 13;

with these:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
const static uint8_t SS   = 53;
const static uint8_t MOSI = 51;
const static uint8_t MISO = 50;
const static uint8_t SCK  = 52;
const static uint8_t SS   = 10;
const static uint8_t MOSI = 11;
const static uint8_t MISO = 12;
const static uint8_t SCK  = 13;

That's it. You now have 8Kbytes of RAM for bigger web pages.
Have fun!


Mar 03, 2011, 10:51 pm Last Edit: Mar 04, 2011, 08:06 pm by johnwasser Reason: 1
Since the 'SS' pin is done in software rather than hardware the software uses D10, EVEN ON THE ARDUINO MEGA.  Move that wire back to D10 and it should work.

I have read that you have to set D10 as an output even if you are using a different pin for Slave Select  (each SPI Slave device must use a separate SS signal, usually by selecting different pins).  If this is true you may need to set D53 (hardware SS) as an output even if nothing is connected to it.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


Yes, you are right.
In order to plug the etherShield (ENC28J60) board on the MEGA1280 board, one has to remove the SPI male header pins (10,11,12,13) from the ethershield board and transfer the four SPI pins to MEGAboard's 53,51,50,52 respectively  by soldering wires that end to a new 4-pin male header.

As you said, one can choose to leave the SPI SS signal (digital pin 10) as it is, without any hardware and software changes.

Go Up