Connecting two SPI Masters via SPI

Hi all,

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.

Although i read something on how to set up a arduino as a SPI slave (e.g. Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino), i dont know how to set up the ardunio (or teensy) as a slave while containing its function as a master towards his slaves.

Is there anyone who faced the same or a similar problem?
Or is there an easy solution which i dont see?

Thanks for your time and thoughts

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?

Why not use serial to exchange data between the Arduino and the Teensy?

Hi,

sorry for my late answer.

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.

Thanks for your time and thoughts

Let's go back to basics. Give us a good description of the total project. What are all the slaves? What does each Arduino do etc.

Why is it necessary for two Arduinos to communicate at 260kByte per second (equivalent to 2,600,000 baud if it was a serial connection).

...R

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.

The problem i see there is that the Mega have to receive and transmitt data at the same time.

That can NOT happen, any more than you can talk and listen AT THE SAME TIME.