Arduino Ethernet Shield (W5100) SPI conflict with RFM transceivers

Hi,

I have an issue with the Arduino Ethernet shield combined with an RFM transceiver (this issue was already detected in 2012).

In am currently running an Home Automation gateway on Arduino ATMEGA 2560 combined with an Arduino Ethernet shield and a RFM69 transceiver.

The sketch is compiled with the arduino IDE is 1.6.5-r5.

The gateway is receiving radio messages asynchronously (using the RFM69 library of Felix Rusus) and sends data to an MQTT broker (on Raspberry Pi) through Ethernet using the PubSubClient ( Nick O'Leary version 2.3) library.

Using the keep alive “loop()” function which asynchronously sends ping to the broker, my Arduino is randomly hanging.

As far I can debug it, it is related to a conflict between the Radio Interrupt and the SPI selection of the Ethernet module.

This issue is described in several forums (http://forum.jeelabs.net/comment/1832#comment-1832, http://harizanov.com/2012/04/rfm12b-and-arduino-ethernet-with-wiznet5100-chip/, Arduino Mega + Ethernet-Shield + SD + RFM12B hängt sich nach einigen Minuten auf - Deutsch - Arduino Forum).

Even if the explanation about the type of Arduino board (I confirm that I have the issue with all Arduino Ethernet SHIELD and perhaps also with the Arduino Ethernet, but not tested) and the usage of a 74LVC1G14DBV shmitt-trigger for the Slave Select (SS) is a little bit cloudy (I have an official Arduino Ethernet shield using single 74LVC1G125DCK and Chinese clones running with a 74LVC1G14DBV chip), the problem is actually solved by disabling the interrupt of the W5100 when the SS is activated.

This by simply in my case changing the W5100.h library from:

#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)
inline static void initSS() { DDRB |= _BV(4); };
inline static void setSS() { cli ();PORTB &= ~_BV(4); };
inline static void resetSS() { PORTB |= _BV(4); sei();};

I wonder why this change is not officially taken into account in the standard Ethernet library.

Robert

Sorry for this note, the problem is solved by the RFM69 library.
Robert