Hello,
I’m using an Arduino Ethernet Shield with a Mega board.
In order to get Ethernet running, I’ve mapped these pins:
53 → 10
51 → 11
50 → 12
52 → 13
Only these pins are mapped for the Ethernet board functionality. My Ethernet-Shield is not attached directly, because there is an additional board between the Mega and Ethernet Shield that does this mapping. So the mapping between these pins is hardfixed.
And here comes the problem: In the libraries\Ethernet\utility\w5100.h , I’ve found the hard-coded SS-PIN here:
#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); };
#else
inline static void initSS() { DDRB |= _BV(2); };
inline static void setSS() { PORTB &= ~_BV(2); };
inline static void resetSS() { PORTB |= _BV(2); };
#endif
According to pins_arduino.c, PB4 is Pin 10 - so it doesn’t cause any trouble if you attach the Shield directly on the board, because you have then a direct Pin 10 <-> Pin 10. But in my case I need to specifically use Pin 53 as SS-Pin. Leaving the default definitions and using an additional wire to map Pin 10 → Pin 10, the Ethernet Shield works.
Now I’d like to use Pin 53 for SS, so I have changed the code in w5100.h:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
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
And PB0 is Pin53 according to pins_arduino.c
But somehow, this doesn’t work on Pin53 as SS.
I’ve also tried to use many different custom pins, and if I change the definition here and connect the specified pin to the shield, it works.
SS as Pin53 is not functional in any way.
Is there any trick to use Pin53 as SS? Is there any advantage/disadvantage over using a special pin or can I use any? (problem is that I already have my platine that has the pin 53 mapped)