i got two microcontrollers (teensy 3.6 and arduino mega) which both use SPI to communicate with certain slaves. Now these two SPI Masters have to exchange data.
PaulS:
Why not use serial to exchange data between the Arduino and the Teensy?
As a transfer rate of ~260kByte/s is needet i choosed SPI. As far as i know Serial reaches ~14kByte/s maximum which is far to less.
PaulS:
How is the Arduino or the Teensy supposed to know, at any given time, whether it is supposed to be acting as master or acting as slave?
Thats exactly the problem i see there. The Mega use SPI only to send data to his slaves, it dont receive any. Is this something you could exploid? The problem i see there is that the Mega have to receive and transmitt data at the same time.
As a transfer rate of ~260kByte/s is needet i choosed SPI. As far as i know Serial reaches ~14kByte/s maximum which is far to less.
A UNO can transfer up to 250kB/s (2Mb/s) using it's USART. I guess a Teensy 3.6 should be able to do the same.
The problem i see there is that the Mega have to receive and transmitt data at the same time.
No, the problem is that you would not only have to switch modes but you have to cut the connection between the two MCUs (on all SPI bus lines) while both are masters otherwise you may have short circuits. I don't know if you're able to construct such a circuit.