Ethernet stops working after SPI access

Thank you for your quickly answer.. ok... My SPI device works with MODE3 ....

eddy_grosse8: My SPI device works with MODE3 ....

That is probably causing your grief. I do not have a mode 3 device to check, but I would try modifying the SPI mode before and after each call to a device that uses another SPI mode in the same fashion as the SS pin. If your new SPI device uses pin 5, then:

// set SPI mode to 3
SPI.setDataMode(SPI_MODE3);
// set SS LOW
digitalWrite(5,LOW);
// do your transfer
SPI.transfer(0xf0);
// set SS pin HIGH
digitalWrite(5,HIGH);
// set mode back to 0
SPI.setDataMode(SPI_MODE0);

I have not tried this because I do not have a mode 3 device. Let me know how it does.

edit: I forgot a semicolon. Corrected now.

Ok ..Thanks it give a bit of Hope..

Just other question..

Should i supposse that i don´t need to write digitalWrite(10, HIGH) (for the reasons described in your previous post) and just change the SPI Mode each time that i call my other SPI device?

Thanks..

You must manage the SPI slave select pins until the setup is run for each device. Before you run Ethernet.begin(mac), you should disable any other SPI devices. Do not set the SPI mode in setup. Leave it at mode 0 except when reading/writing to your new mode 3 device.

void setup() {
   Serial.begin(9600);

   // disable the SD SPI in case there is a card in the slot
   pinMode(4,OUTPUT);
   digitalWrite(4,HIGH);

   // disable new device SPI
   pinMode(5,OUTPUT);
   digitalWrite(5,HIGH);

   // Now do w5100 init
   Ethernet.begin(mac,ip);
   // Ethernet.begin() leaves the w5100 SPI enabled. This is a bug. Here is the patch:
   digitalWrite(10,HIGH);

   // rest of your setup stuff.
}

edit: I forgot to patch the Ethernet.begin bug. Corrected now.

Hey SurferTim: :)

Thank you very very much...

finally It works...

That was the problem...I just put on the end from my transfer function a command with SPIMODE(0)..

I want to make all the functions working but it will take a bit of time .... ;).

Another problem would how to read de values from the position register (a very cool feature ) in live Time.. think is a bit difficult because that whould mean to have 2 chips on the same time working....??

my idea is using a bluetooth chip to send the values.... What do you think about this??

Thanks Thanks..Thanks..