Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Multiple Slaves on SPI

  1. #1
    Junior Member
    Join Date
    Oct 2016
    Posts
    17

    Multiple Slaves on SPI

    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
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,599
    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?)

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,734
    Maybe this can help?

    https://www.dorkbotpdx.org/blog/paul...ign_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().

  4. #4
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,332
    That's a great article on SPI. What size resistors would you recommend for the CS pins?

  5. #5
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,599
    i use 10k ohm for my spi devices, took a chance and tested at 30mhz spi and it didnt seem to hinder the performance

  6. #6
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,332
    you got me curious tonton81 so I did a little googling - thought 10k might be too high but found this article http://www.microchip.com/forums/m148739.aspx that supports that size resistor, I think. I think it is also recommending one on MISO? Last post is interesting also.

  7. #7
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,599
    Yes, my canbus controller and mcp23s17 setup has a MISO pullup, this stops random data from flowing when the devices reboot/sync.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •