RF22 Shield (Sparkfun) and Ethernet Shield (WizNet)

91 views
Skip to first unread message

David Vaughn

unread,
May 7, 2014, 3:02:21 PM5/7/14
to rf22-a...@googlegroups.com
So I currently have an RF22 Shield from Sparkfun and just received a Wiznet Ethernet shield from eBay.  By everything I read it appears I can make the two function together but I'm not 100% on how I do that.  Does anyone have any experience with this that can help walk me through it?  Do I need to cut the trace and relocate the NSEL (SS) pin? If I change the SS pin, I still need to disable the interrupts while transferring on the Ethernet correct, and if so how do I do that?

stevech

unread,
May 7, 2014, 4:00:47 PM5/7/14
to rf22-a...@googlegroups.com
I've used both the RFM22 and a Wiznet 812MJ.
Each device needs an independent slave select (SS) bit.
The Wiznet may not need an interrupt bit connection to the MCU since the Arduino library (the one I've seen) does not use Interrupts with the Wiznet. You'll need to confirm this based on which library you'll use.
Without interrupts, your code will have to poll the wiznet to see if a message has arrived. This involves using the SPI port.
Ah, here's the challenge: If the RF22 library as is the norm, uses interrupts from the RFM22 radio, then the RF22 library interrupt service will use the SPI port. You will encounter a collision, where the Wiznet non-interrupt driven interface is using the SPI port and once in a while the RFM22 will interrupt and both are using the same SPI port.
This contention for the SPI port among 2+ interfaces is well known problem due to the lack of coordination among library authors, and the lack of a simple operating system to help.
There is great discussion and  lots of proposals on solutions, on the Arduino developer's forum, and the Teensy3 forum.

About all you can do now is to code to prevent collision in access to the SPI. Some approaches
  1. Use the software SPI driver to talk to the RFM22. No contention. Still need independent SS bits/pins
  2. Wire the wiznet's interrupt request to an I/O pin. Set pin as an INPUT.  Don't enable interrupts from that pin. When polling the Wiznet for status of newly arrived packet, read the pin with the interrupt request from the Wiznet. If true (0), there's some reason to use SPI to read the wiznet's status. You need to prevent the RFM22 from interrupting while you use the SPI to talk to the Wiznet. Some ways to do this are (a) disable pin interrupt from the RFM22 then use the SPI port to get status then perhaps data from the wiznet.When done, reenable the pin interrupt for the RFM22. You'll need to have the RH library change to use the interrupt condition of "HIGH" rather than "FALLING", for this to work.
  3. Put the RFM22 radio in idle mode  while using the  SPI port to talk to the Wiznet. You may miss arriving messages on the radio.
  4. Other more complex schemes

David Vaughn

unread,
May 7, 2014, 8:50:28 PM5/7/14
to rf22-a...@googlegroups.com
Steve,

Thanks for the reply.  In looking at your options and reviewing my code, I think option 3 would be the best because most of my interaction is serial (i.e. receive message via RF22 then send a UDP packet on the Ethernet line then go back to listening).  The only time I could see it being a problem is in the RARE event that my wife and I start our cars within ms of each other and therefore the transmitters send RF messages within ms of each other. I've also attached my code by the way in case anyone would like to view it.

That being said, I still have to supply a different SS pin for the RF22 shield correct?  Easy enough, but wanted to make sure before I do so.  Other than that just code setModeIdle() before my UDP sends and setModeRx() after them?  Will I also have to change the interrupt pin to pin 3?
Vehicle_Sensor_Server.ino

stevech

unread,
May 7, 2014, 10:24:37 PM5/7/14
to rf22-a...@googlegroups.com
Yes, each SPI slave needs a unique SS pin on the hose MCU.

There are other options for sharing the SPI port - - gets involved.
Reply all
Reply to author
Forward
0 new messages