Giusto per togliermi una curiosità, acik, puoi provare ad usare questa versione modificata della SPI.cpp? Io non posso provare fino a domani pomeriggio.
Ho fatto questa modifica:
void SPIClass::begin() {
// Set SS to high so a connected chip will be "deselected" by default
digitalWrite(SS, HIGH);
// When the SS pin is set as OUTPUT, it can be used as
// a general purpose output port (it doesn't influence
// SPI operations).
pinMode(SS, OUTPUT);
// Warning: if the SS pin ever becomes a LOW INPUT then SPI
// automatically switches to Slave, so the data direction of
// the SS pin MUST be kept as OUTPUT.
SPCR |= _BV(MSTR);
SPCR |= _BV(CPOL); //Questa
SPCR |= _BV(CPHA); //E questa
SPCR |= _BV(SPE);
// Set direction register for SCK and MOSI pin.
// MISO pin automatically overrides to INPUT.
// By doing this AFTER enabling SPI, we avoid accidentally
// clocking in a single bit since the lines go directly
// from "input" to SPI control.
// http://code.google.com/p/arduino/issues/detail?id=888
pinMode(SCK, OUTPUT);
pinMode(MOSI, OUTPUT);
}
Visto che il W5100 può lavorare nelle modalità 0 e 3 della SPI (ci sono 4 modalità) e di default Arduino usa la 0, perché non provare con la 3?
EDIT: C'è una funzione della libreria della SPI che fa proprio questo:
SPI.setDataMode(3);
Ma deve essere eseguita prima di chiamare la Ethernet.begin();
SPI.cpp (1.73 KB)