I would be very grateful if the forum could help me to a better insight into how SPI works and, in particular, why I am failing to get my set up to behave. This is the hardware stack that I am trying to get to work:
5" TFT display with SPI-connected flash chip
Display shield
Ethernet shield (1 or 2)
SD card on the Ethernet board
Arduino Due
The library stack is
#include <SPI.h>
#include <SdFat.h>
#include <Ethernet.h> (or #include <Ethernet2.h>)
#include <ICMPPing.h>
#include <UTFT.h>
#include <UTFT_GHL.h>
The Ethernet connection receives asynchronous UDP data for the intended application. The application then processes the data, saves stuff to the SD card and writes information to the display using fonts obtained from the flash chip. I am using the Ethernet library (or the Ethernet2 library for the v2 card) and SdFat. The flash chip uses the UTFT_GHL library. There are, therefore, three users of the SPI: Ethernet, SD card and flash chip.
It doesn't work!
To try to narrow down the problem I wrote a simple app that pings Google via the Ethernet card, reads/writes/deletes files on the SD card and writes stuff to the display in a continuous loop. I'm happy to post this code if it will help.
What happens?
Each of the SPI interfaces works fine on its own. If I run the Ethernet and SD card together, as soon as I do anything with the SD card the Ethernet interface dies so conclusively that it hangs the entire machine when the next ping is sent. The same thing happens if I run Ethernet with Flash font screen printing. The only combination that does work is SdFat R/W/D and UTFT_GHL reading the flash to get its fonts.
Anecdotally the Ethernet card doesn't play nicely with other things on the SPI and my experience seems to be adding to that sorry tale. It seems to me that this is something that it ought to be possible to fix once and for all but I am no expert when it comes to the innards of these drivers/libraries and am a relatively recent convert to programming in C. So I am appealing to those with greater knowledge and experience than me to help out with this one.
Any insight gratefully received!
Thanks in advance.
John.