Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
09.02.2010 at 18:12:42
News: Server upgrade went fine, you are now at the new system


Pages: 1 2 
Arduino + Ethernet Shield + Another SPI device (Read 1204 times)
metRo_
YaBB Newbies
*
Offline

Arduino rocks

Posts: 37

Arduino + Ethernet Shield + Another SPI device
20.07.2009 at 00:24:24
 
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
Back to top
 
 
View Profile   IP Logged
EmilyJane
Senior Member
****
Offline



Posts: 455
Dallas, Texas
Re: Arduino + Ethernet Shield + Another SPI device
Reply #1 - 20.07.2009 at 01:13:19
 
What is the other device? Does it have a library or an example sketch showing its use?
Back to top
 
 
View Profile   IP Logged
metRo_
YaBB Newbies
*
Offline

Arduino rocks

Posts: 37

Re: Arduino + Ethernet Shield + Another SPI device
Reply #2 - 20.07.2009 at 01:21:47
 
Back to top
 
 
View Profile   IP Logged
EmilyJane
Senior Member
****
Offline



Posts: 455
Dallas, Texas
Re: Arduino + Ethernet Shield + Another SPI device
Reply #3 - 20.07.2009 at 01:36:46
 
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.
Back to top
 
 
View Profile   IP Logged
EmilyJane
Senior Member
****
Offline



Posts: 455
Dallas, Texas
Re: Arduino + Ethernet Shield + Another SPI device
Reply #4 - 20.07.2009 at 01:55:46
 
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.
Back to top
 
 
View Profile   IP Logged
kg4wsv
God Member
*****
Online



Posts: 1904

Re: Arduino + Ethernet Shield + Another SPI device
Reply #5 - 20.07.2009 at 11:56:31
 
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
Back to top
 
 
View Profile   IP Logged
Ran Talbott
God Member
*****
Online

Incorrigible
tinkerer

Posts: 798
Rural Arizona
Re: Arduino + Ethernet Shield + Another SPI device
Reply #6 - 20.07.2009 at 14:30:31
 
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
Back to top
 
 
View Profile   IP Logged
metRo_
YaBB Newbies
*
Offline

Arduino rocks

Posts: 37

Re: Arduino + Ethernet Shield + Another SPI device
Reply #7 - 20.07.2009 at 14:35:56
 
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?
Back to top
 
 
View Profile   IP Logged
kg4wsv
God Member
*****
Online



Posts: 1904

Re: Arduino + Ethernet Shield + Another SPI device
Reply #8 - 20.07.2009 at 14:53:03
 
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
Back to top
 
 
View Profile   IP Logged
EmilyJane
Senior Member
****
Offline



Posts: 455
Dallas, Texas
Re: Arduino + Ethernet Shield + Another SPI device
Reply #9 - 20.07.2009 at 17:40:34
 
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.
Back to top
 
 
View Profile   IP Logged
metRo_
YaBB Newbies
*
Offline

Arduino rocks

Posts: 37

Re: Arduino + Ethernet Shield + Another SPI device
Reply #10 - 20.07.2009 at 21:14:17
 
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
Back to top
 
 
View Profile   IP Logged
EmilyJane
Senior Member
****
Offline



Posts: 455
Dallas, Texas
Re: Arduino + Ethernet Shield + Another SPI device
Reply #11 - 20.07.2009 at 21:26:14
 
Worth a try.
Back to top
 
 
View Profile   IP Logged
Ran Talbott
God Member
*****
Online

Incorrigible
tinkerer

Posts: 798
Rural Arizona
Re: Arduino + Ethernet Shield + Another SPI device
Reply #12 - 20.07.2009 at 22:55:34
 
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   Smiley

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.   Grin  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
Back to top
 
 
View Profile   IP Logged
metRo_
YaBB Newbies
*
Offline

Arduino rocks

Posts: 37

Re: Arduino + Ethernet Shield + Another SPI device
Reply #13 - 20.07.2009 at 23:09:36
 
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?
Back to top
 
« Last Edit: 21.07.2009 at 12:07:23 by metRo_ »  
View Profile   IP Logged
Ran Talbott
God Member
*****
Online

Incorrigible
tinkerer

Posts: 798
Rural Arizona
Re: Arduino + Ethernet Shield + Another SPI device
Reply #14 - 21.07.2009 at 01:41:05
 
You need a second try  Smiley

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
Back to top
 
 
View Profile   IP Logged
Pages: 1 2