Spi Slave Shared by 2 masters

Thread Starter

cgha20@yahoo.com

Joined Oct 21, 2009
82
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
 

Papabravo

Joined Feb 24, 2006
22,065
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.
 

Thread Starter

cgha20@yahoo.com

Joined Oct 21, 2009
82
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,
 

tshuck

Joined Oct 18, 2012
3,534
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?
 

Thread Starter

cgha20@yahoo.com

Joined Oct 21, 2009
82
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
 
Top