Multiple Slaves on SPI

Status
Not open for further replies.

SimonWakley

Active member
I have been trying to get a handle on running more than one device on SPI when the settings are different. There are a few threads on this and it seems other people are having issues too. I have the Adafruit TFT using Paul's faster library and to works fine. I have a Wiznet 821io and as I said in my prior post, if I run either one, it works totally fine. The moment I try to enable them both it fails on tft.begin even if I try to set up a Settings and use that:

#define TFT_SPI_CLOCK 30000000
#define WIZNET_SPI_CLOCK 14000000

SPISettings Tft_Settings(TFT_SPI_CLOCK, MSBFIRST, SPI_MODE0);
SPISettings Wiznet_Settings(WIZNET_SPI_CLOCK, MSBFIRST, SPI_MODE3);


SPI.beginTransaction(Tft_Settings);
tft.begin();

I have also tried SPI.setCS but that is not recommended/intended to be used in sketches, and there is some complexity with the Tft as it also has a D/C line

I will include my project, but it's gotten kinds of messy with all the different things I have tried and possibly I have confused some setting and that's why it is not working.

If someone could assist me with this, I would be willing to remunerate - either Venmo or Bevmo :)

Thanks,

Simon
 

Attachments

  • WakrinoLedSerialTftTouchNW.ino
    11 KB · Views: 61
what teensy you have? if you have a second SPI bus put one of the devices on a different bus.
Some devices don’t share properly because they don’t release the MISO line properly to tristate
There might be an issue (I think with mode3??) when changing SPI modes, where a dummy byte must be sent after SPI.transactions but before asserting the SPI CS line. (bug?)
 
Maybe this can help?

https://www.dorkbotpdx.org/blog/paul/better_spi_bus_design_in_3_steps

A very common problem is lack of pullup resistors on the CS pins, or code to drive them all high (inactive) before initializing any of the SPI chips. Without resistors or code, the CS pins can be any random voltage. The W5200 chip on the WIZ820io module is particularly susceptible to accidentally hearing communication from other chips and getting into an unrecoverable mode. It's easy to solve with real pullup resistors on all the CS pins, or code that drives them all high at the beginning of setup().
 
That's a great article on SPI. What size resistors would you recommend for the CS pins?
 
i use 10k ohm for my spi devices, took a chance and tested at 30mhz spi and it didnt seem to hinder the performance
 
Yes, my canbus controller and mcp23s17 setup has a MISO pullup, this stops random data from flowing when the devices reboot/sync.
 
Status
Not open for further replies.
Back
Top