Go Down

Topic: Mighty 1284p SPI / Ethernet how to get it work ? (Read 3 times) previous topic - next topic

sync

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 ?

sync

I figured out it was located in pins_arduino.h

Code: [Select]
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.

Nick Gammon

What Ethernet card/board are you using and how is it connected?
http://www.gammon.com.au/electronics

sync

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.

Nick Gammon

Do you mean the pins on the chip?

From this page:

http://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/

Code: [Select]

                      +---\/---+
           (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).
http://www.gammon.com.au/electronics

sync

Actually, i was referring to D4, D5, D6, D7  :smiley-red:

Anyone here has Ethernet working on Mighty 1284p ?

Nick Gammon

Can you post the exact sketch you are trying? In code tags.
http://www.gammon.com.au/electronics

sync

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.

Nick Gammon

Looking at w5100.h:

Code: [Select]
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.
http://www.gammon.com.au/electronics

CrossRoads

maniacbug's 1284 core files don't cover that?
He's been pretty thorough with those.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon

I don't know. I just looked in w5100.h which is part of the Ethernet library.
http://www.gammon.com.au/electronics

sync


Nick Gammon

http://www.gammon.com.au/electronics

Nick Gammon

Try changing, in the code I posted:

Code: [Select]
#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:

Code: [Select]
#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.
http://www.gammon.com.au/electronics

sync

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. :-)


Go Up