Hey guys. very new hear and in fact very new to Arduino's.
I was up all night trying to wire the ATMega1284 to a pretty standard ENC29J60.
I checked the ENC29j60 on a 2560 wired on pins 54,53,52,51 iv'e also had it working perfectly well on bread boarded Atmega328p pins 11,12,13 and worked an absolute treat. but on the ATmega1284p I'm getting absolutely no where.
If you have the ethercard library running with a Uno and a ENC28J60, you are no longer new to Arduino. It is something for advanced users.
The Mega (and Mega2560) use the SPI bus the same way, but you have to adapt the pin numbers for the Mega.
If a different ChipSelect is used, the SS pin of the Mega2560 has to be set as output, to make the SPI hardware working.
The function "xferSPI()" in "enc28j60.cpp" is the function to communicate with the chip. It uses the SPI hardware by direct register access.
The ChipSelect line is set with the begin() function (the third csPin parameter).
I think if you set that to the SS pin of the Mega, it should work.
The SS has to be output, regardless of which pin you use for ChipSelect. That was what I ment in my previous post. That is what is happening in that initSPI() code. That is good, you don't have to set the SS pin as output yourself.
The begin() function has a third parameter for the ChipSelect. You could use the SS pin, but also another pin can be use for the ChipSelect.
If you don't use the third parameter, perhaps it defaults to pin 8 or so.
I have a Mega2560 with Ethernet Shield, and a Uno with ENC28J60 and ethercard. So I don't have your combination, but with the right ChipSelect it should work.