Spi Slave Shared by 2 masters

Discussion in 'General Electronics Chat' started by cgha20@yahoo.com, Mar 25, 2015.

  1. cgha20@yahoo.com

    Thread Starter Active Member

    Oct 21, 2009
    61
    0
    Gents,
    I have two microcontrollers that will need to share the same 4 SPI slaves. In one scenario, one microcontroller will access the slaves through SPI BUS. In another scenario, the other microcontroller needs to access slaves through same bus. Both masters will never try to access the SPI slaves at the same time. Can I simply connect both masters to the SPI bus? Or will it require some intelligence to remove one microcontroller from circuit as the other is working.

    Thanks
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    It would be best for you to interface to the bus with tri-state drivers that can be put into high impedance mode when inactive. There is no problem with the inactive master listening to the other master.
     
  3. cgha20@yahoo.com

    Thread Starter Active Member

    Oct 21, 2009
    61
    0
    I am using microchip microcontroller. I guess i can use TRISA, TRISB etc registers to set input or output (meaning high impedance state) in one case, and then change in other case,
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    I would also recommend pullup/pulldown resistors on the lines to the memory as reasonable.

    As a potential alternative, is there a reason you couldn't have one of the masters talk to the other and request and send data that way, with only one device as a SPI master?
     
  5. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,500
    2,366
  6. cgha20@yahoo.com

    Thread Starter Active Member

    Oct 21, 2009
    61
    0
    Tshuck Original microcontroller has no more available anything. All Spi, UART, USB, and GPIOs already being used. 2nd microcontroller needs to pick up the rest. The original microcontroller board cannot be changed. 2nd microcontroller will have a RS485 high speed to dump memory
     
Loading...