Mighty 1284p SPI / Ethernet how to get it work ?

Hey!

I can't figure out how change from default Arduino 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). to 4, 5, 6, 7 to match The Mighty 1284p ?
Anyone ?

I figured out it was located in pins_arduino.h

static const uint8_t SS   = 4;
static const uint8_t MOSI = 5;
static const uint8_t MISO = 6;
static const uint8_t SCK  = 7;

But, i still can't get any basic Ethernet examples to work, it just hang. I've tried with 4 different 1284p, no love.

What Ethernet card/board are you using and how is it connected?

Nick,
Pretty much straightforward set-up. It works with any atmega i have here but not the 1284p, go figure. I've tried all week.

I use an Ethernet Shield (no SD) and i power it with 3.3 v, connect the ground of course. Then, i wire pins 10, 11, 12 and 13 to the 1284p 4, 5, 6, 7 like this 10->4, 11->5, 12->6, 13->7
The 1284p operates correctly until it hit line Ethernet.begin(mac)
It freeze right there.

Like i said, i do the same thing for months with other megas and it is all fine.
FYI, i've also tried Jeelabs Ethercard, using ethercard library, diferents SS_pin but same problem. Again, works fine with other megas.

Thanks for the help.

Do you mean the pins on the chip?

From this page:

                      +---\/---+
           (D 0) PB0 1|        |40 PA0 (AI 0 / D24)
           (D 1) PB1 2|        |39 PA1 (AI 1 / D25)
      INT2 (D 2) PB2 3|        |38 PA2 (AI 2 / D26)
       PWM (D 3) PB3 4|        |37 PA3 (AI 3 / D27)
    PWM/SS (D 4) PB4 5|        |36 PA4 (AI 4 / D28)
      MOSI (D 5) PB5 6|        |35 PA5 (AI 5 / D29)
  PWM/MISO (D 6) PB6 7|        |34 PA6 (AI 6 / D30)
   PWM/SCK (D 7) PB7 8|        |33 PA7 (AI 7 / D31)
                 RST 9|        |32 AREF
                VCC 10|        |31 GND
                GND 11|        |30 AVCC
              XTAL2 12|        |29 PC7 (D 23)
              XTAL1 13|        |28 PC6 (D 22)
      RX0 (D 8) PD0 14|        |27 PC5 (D 21) TDI
      TX0 (D 9) PD1 15|        |26 PC4 (D 20) TDO
RX1/INT0 (D 10) PD2 16|        |25 PC3 (D 19) TMS
TX1/INT1 (D 11) PD3 17|        |24 PC2 (D 18) TCK
     PWM (D 12) PD4 18|        |23 PC1 (D 17) SDA
     PWM (D 13) PD5 19|        |22 PC0 (D 16) SCL
     PWM (D 14) PD6 20|        |21 PD7 (D 15) PWM
                      +--------+

You appear to be out by one in each case. (SS is pin 5 not pin 4).

Actually, i was referring to D4, D5, D6, D7 :blush:

Anyone here has Ethernet working on Mighty 1284p ?

Can you post the exact sketch you are trying? In code tags.

All sketch from the Ethernet examples. Basic stuff.
Arduino 1.0, 1.0.1 on either Windows7 or Mac OS X latest

I'm very confused at this point, i manage to find solution all by myself most of the time, must be a silly thing hanging there.

Looking at w5100.h:

private:
#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); };
#elif defined(__AVR_ATmega32U4__)
  inline static void initSS()    { DDRB  |=  _BV(6); };
  inline static void setSS()     { PORTB &= ~_BV(6); };
  inline static void resetSS()   { PORTB |=  _BV(6); }; 
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
  inline static void initSS()    { DDRB  |=  _BV(0); };
  inline static void setSS()     { PORTB &= ~_BV(0); };
  inline static void resetSS()   { PORTB |=  _BV(0); }; 
#else
  inline static void initSS()    { DDRB  |=  _BV(2); };
  inline static void setSS()     { PORTB &= ~_BV(2); };
  inline static void resetSS()   { PORTB |=  _BV(2); };
#endif

They don't seem to have a define for the Atmega1284 and the default would appear to be incorrect for you.

maniacbug's 1284 core files don't cover that?
He's been pretty thorough with those.

I don't know. I just looked in w5100.h which is part of the Ethernet library.

Nothing else we can do ? :roll_eyes:

Don't ignore reply #8.

Try changing, in the code I posted:

#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); };

to:

#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); };

I didn't look further than that. However it appears that the 1284P is not catered for in w5100.h. Maybe search for similar things in the Ethernet library.

Well i did change the lines inside w5100.h but it still doing the same.
Feels like i don't know what i'm doing. :slight_smile:

funny-science-news-experiments-memes-dog-science-fuzzy-logic.jpg

Well there is good news and bad news.

The good news is, I've reproduced your problem. :slight_smile:

The bad news is, the fix is not totally working. :frowning:

I hooked up my 1284P to my Ethernet Shield Rev 3, and found that (using the logic analyzer) although the signals were going out as expected, nothing was coming back.

Then I took a closer look and realized that the shield is designed to interface with the ICSP header (underneath) rather than pins 10/11/12/13 because it is designed to be plugged into other boards, like the Mega.

So I moved SCK, MISO, MOSI to the ICSP header.

       Atmega1284P    Ethernet Shield

SS     pin 5  (D4)      D10 on the shield
MOSI   pin 6  (D5)        ICSP pin 4
MISO   pin 7  (D6)        ICSP pin 1
SCK    pin 8  (D7)        ICSP pin 3

Now at least it got a response. But still rather flaky. It didn't hang on the connection any more. Just "failed".

I made the change I mentioned to the w5100.h file. I experimented with slowing down SPI:

  // start the Ethernet connection:
  Ethernet.begin(mac, ip);
  SPI.setClockDivider(SPI_CLOCK_DIV16);   // slow down SPI

It connected a couple of times, it got data back a couple of times. You may have more luck with your wiring. I think I have a lot of noise here, I am having trouble uploading the sketch.

This should get you closer.

Further to the above, it appears that during testing I crashed the server I was connecting to. So it might be more reliable if you implement all those changes. Maybe. :slight_smile:

Was any solution to this ever found? I'm experiencing the same with 1284P. I tried both Calunium and Mighty1284 with the same result: a hanging 1284P when I call ethernet.begin(...)

I found that the issue only exists when attempting to use DHCP.

I just got back from summer hollidays, sorry for not giving back any infos soon after Nick sent his message about a fix. I did not had time to tried.
Really, only DHCP does that ? i tried both fixed IP and DHCP and the result was the same. IIRC last month test.

kfuglsang:
I found that the issue only exists when attempting to use DHCP.