Pages: [1]   Go Down
Author Topic: Ethershield ENC28J60 connection to MEGA1280 or 2560  (Read 2484 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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;
#else
const static uint8_t SS   = 10;
const static uint8_t MOSI = 11;
const static uint8_t MISO = 12;
const static uint8_t SCK  = 13;
#endif

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

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 202
Posts: 8714
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 04, 2011, 02:06:55 pm by johnwasser » Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: