Go Down

Topic: Arduino + Ethernet Shield + Another SPI device (Read 6248 times) previous topic - next topic

metRo_

Any idea of how i can use ethernet shield and another SPI device? I'm think in a mux but the ethernet shield will always connect to arduino :S

EmilyJane

What is the other device? Does it have a library or an example sketch showing its use?

metRo_

I'm using that library http://code.google.com/p/jeelabs/source/browse/trunk#trunk/libraries/RF12%3Fstate%3Dclosed

The device is a RFM12

EmilyJane

It looks like the SPI data transfer is happening in an ISR in the RFM12 library. I'm not at all sure how that will affect Ethernet.

EmilyJane

I would change /SS to another pin in RF12.cpp and see if you can get that to work by itself and then add in the Ethernet Shield later.

kg4wsv

The official ethernet shield does not play well with others.  The Wiznet chip is not a well behaved SPI peripheral in that it does not put MISO in a high impedance state when its CS input is inactive.  It has a separate "SPI enable" input that does that.  The official ethernet shield simply ties SPI enable high, so that MISO is always active.

You could bit-bang SPI on another set of pins for the second peripheral.

-j

Ran Talbott

The datasheet for the WIZ811MJ (used on Adafruit's current Ethernet shield) says it has an inverter on-board that properly drives SPI_EN from SS.

It also says one of the differences from the older WIZ810MJ is that the old module requires control of SPI_EN.

So maybe it depends on which version of the Ethernet shield you have?  Were there boards shipped that used the WIZ810MJ module?

I've got some SPI LED driver chips,  and I've been meaning to put together a numeric display with one.  I have another project due tomorrow,  but I can try to get the display to co-exist with the WIZ811MJ later.

Have you looked closely at the standard Ethernet libraries to see whether they have any features like using interrupts (as the RFM12 apparently does),  or depending on the previous state of the SPI registers,  that might make for ugly surprises?

Ran

metRo_

I will receive my ethernet shield friday. I bought it to tinker.it.

So the first thing to do is try to use rfm12 with another /SS pin ? And after try to use it with the ethernet.

kg4wsv do you have an idea?

LAST OPTION: And if connect the shield in a breadboard and after i use a mux?

kg4wsv

Quote
So maybe it depends on which version of the Ethernet shield you have?

I was referring to the official ethernet shield, as described here.  Hopefully other shields work around this issue.

If you've got a standard Arduino ethernet shield, the RFM12 library will not work with it because a) the ethernet shield won't go hi-Z on MISO, and b) they're both hard coded to use 10 as the SS.  You can hack the software to get around the latter, but I don't know how to get around the MISO problem without either completely rewriting the RFM12 library to bit-bang SPI on pins other than 10-13 or doing some serious hacking on the ethernet shield.

Other ethernet shields that are software compatible with the official shield may or may not have the hi-Z MISO problem, but they'll still be wired to use 10 as SS, which will require changing the RFM12 library to use a different pin for SS.

-j

EmilyJane

I have the 811MJ module but I don't own any other SPI devices so I can't test it out, but I do know it behaves well as an Ethernet Shield.

I'd be tempted to "fix" the Tinker.it shield. There is plenty of clear space on the board to glue a tiny-logic '04 gate, dead bug style. That and a little "blue wire" and you'd be good to go. As a matter of fact, I have some tiny HC14s coming, I'll just do that and see if it breaks anything.

metRo_

And if in last option i use an mux to mux the 10 11 12 13 to the two devices?

       / RFM12
10  --
       \ Ethernet

       / RFM12
11  --
       \ Ethernet

       / RFM12
12  --
       \ Ethernet

       / RFM12
13  --
       \ Ethernet


Ran Talbott

Quote
And if in last option i use an mux to mux the 10 11 12 13 to the two devices?


Then you wind up with a problem.

However,  there is an "else" available   :)

You need to actively drive the SS line on both devices all the time.  So,  no muxing there.

And you can drive both SCLK and MOSI,  so no mux needed there,  either.

I checked the Ethernet schematic,  and there's a 2-pin jumper that allows SEN to be connected to ground.  It should be possible to connect that to a different digital pin,  and use that to drive SEN.

Since SEN is active-high,  and SS is active-low,  it might be possible to connect the RFM12's SS to the Ethernet's SEN.  Well,  of course it's possible,  but I'm not sure it will work.   ;D  There could be a timing problem:  since SEN is doing some bus reconfiguration,  there might be a time lag before it takes effect that could still cause interference.  Or there might not.

Either way,  it's worth a try.  If it doesn't work out,  just assign a different pin to the RFM12's SS,  and add delay(s) around the toggling of SEN as needed to make it work.

It's definitely easier than trying to build a mux.

Ran

metRo_

#13
Jul 21, 2009, 12:09 am Last Edit: Jul 21, 2009, 01:07 pm by metRo_ Reason: 1
Thanks for all yours help.

Edited:

First Try.
1-Connect SEN to a digital pin to control it.
2-Connect RFM12 SS to the SEN of ethernet.
3-Set the Ethernet's SS to 1,  and SEN to 0,  to talk to the RFM12.
4-Set the Ethernet's SS to 0,  and SEN to 1,  to talk to the Ethernet.

It's that?

Ran Talbott

You need a second try  :)

The SS signal is "active low",  and SEN is "active high",   so you need to flip the 1s and 0s in steps 3 and 4.

Set the Ethernet's SS to 0,  and SEN to 1,  to talk to the Ethernet.  Set them opposite to talk to the RFM12.

Someone mentioned that the RFM12 driver is using interrupts.  You'll need to modify that.  You might be able to just disable that interrupt while talking to the Ethernet.  Or you might need to make more complicated changes.

Ran

Go Up