Wednesday, 13 July 2016

stm8 - Is it possible to communicate single SPI slave with Two SPI masters


I am using two STM8 micro-controllers as SPI masters. Master-1 is configured in full duplex mode. And the Master-2 is configured in Receive-only mode. The CS, MISO, MOSI and SCLK lines of Master-1 are connected to the Slave. The CS, MISO and SCLK lines of Master-2 are connected to the Slave. When Master-1 requests data from the slave. Master-1 and Master-2 should receive the data from slave at the same time. And the data should be same. I configured two masters with same baudrate,CPOL and CPHA.


When I am communicating with single master, I could receive the data correctly from the slave. But When I involve the second master in the communication the received data of both master is corrupted. And in the oscilloscope, I could see the SCLK variations on the slave.


What are the things I need to consider while communicating a slave with two masters at the same time.



Answer



As others have already said in the comments to your question - you can't simultaneously have 2 masters on an SPI bus. It just doesn't work that way.
But the setup you describe (ignoring your master/slave terminology) could work.
Only your Master-1 stays being a master. Your existing Slave stays as a slave, and your Master-2 becomes a slave, but you connect its data lines as if it's a master.
So:



schematic


simulate this circuit – Schematic created using CircuitLab


Your Master-1 will Chip-Select both Slave-1 & New-Slave-2(Old-Master-2) at the same time, and then when Slave-1 sends data out on its MISO, this data will be received by Master-1 on its MISO (as expected), and also by New-Slave-2 on its MOSI.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...