Does the Arduino IDE 1.0.6 have a new SPI library? The Teensy Wiki mentions a new SPI library in 1.0.6, but I can't find anything about it in the Arduino Release Notes. The release notes do say 1.5.8 BETA has the new SPI library.
Here's my issue. I have a weather station project that uses a Moteino (like and Uno with an on-board radio) and an Ethernet module which is used to send data to Weather Underground. Initially, my sketch would lock up after a minute or so and I figured out that the radio and Ethernet module weren't playing nice together. I found this post about modifying w5100.cpp to temporarily disable interrupts. Basically, in void W5100Class::setSS(void) there is a cli() at the start of the function, then in void W5100Class::resetSS(void) there is a sei() at the end of the function. This modification worked great, but I don't really like having modified core libraries around. Also, I have a few computers that I use to program Arduinos, so the libraries have to be modified on all of them. Will the new SPI library take care of this interrupt issue so I didn't need a modified version? If so, how would I use the new SPI functions: SPI.beginTransaction(), SPI.endTransaction() and SPI. SPI.usingInterrupt()? Here' s my sketch on GitHub.
Normally the ethernet library uses D10 as the w5100 slave select, and the Moteino also uses D10 for the radio transceiver. If that is the case, you will have problems with both those devices.
SurferTim:
Normally the ethernet library uses D10 as the w5100 slave select, and the Moteino also uses D10 for the radio transceiver. If that is the case, you will have problems with both those devices.
What pin are you using for the ethernet SS?
You're right, I already dealt with that by using a modified library I got from SurferTim.
So that's yet another change to the core libraries. I'd like to keep the changes to a minimum.
SurferTim:
I'm surprised the Moteino radio uses the SPI library during an interrupt. If that is true, then I presume that is what is causing the problem.
I didn't look at who the post was from. I referred to SurferTim not noticing it was you!
I don't know the inner workings of the Moteino, but I guess something like that is going on.
Line 97 is the interrupt handler, and line 103 is the SPI.transfer() call.
ScottG:
Edit: Is there anything I can take advantage of in the new SPI library?
Do you know what is supposedly different that would overcome a SPI function call during an interrupt if using the new SPI library? The problem would arise if another device (like the w5100 or SD card) was in the middle of a SPI function with its slave select LOW when the interrupt is triggered. That means both devices SPI would be active simultaneously. That is bad news.
edit: IDE v1.0.6 SPI library has no provisions from preventing a SPI bus collision under the circumstances above.
It appears that IDE v1.5.8 does have provisions for using the SPI in an interrupt.
edit2: To answer my own question above, the IDE v 1.5.8 appears to use a hardware interrupt mask to disable just the one interrupt used by a device using the SPI in an interrupt call in the beginTransaction call, then resets the interrupt mask byte at the endTransaction call.
SurferTim:
edit2: To answer my own question above, the IDE v 1.5.8 appears to use a hardware interrupt mask to disable just the one interrupt used by a device using the SPI in an interrupt call in the beginTransaction call, then resets the interrupt mask byte at the endTransaction call.
We're starting to venture into a level of programming I'm not really competent in :~ What is the effect of your edit2 comment?
Also, do you think Serial.print() would cause problems with the DavisRFM69 library?
As I see it, the libraries must have the v1.5.8 mods to use the SPI.transfer function in an interrupt. It requires the device using a SPI function in an interrupt to "register" that interrupt number with the SPI library with the SPI.usingInterrupt() function. Then when another device calls SPI.beginTransaction(), it will disable only that interrupt during the transaction instead of disabling all of the interrupts like cli does. But that is just a guess right now.
It appears some device libraries have the v1.5.8 mods already. Adafruit apparently has included these mods in their version of the CC3000 WiFi device. They are really on top of new stuff.