Go Down

Topic: Connecting two SPI Masters via SPI (Read 405 times) previous topic - next topic

thor7

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. http://www.gammon.com.au/forum/?id=10892&reply=1#reply1), 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

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?

Why not use serial to exchange data between the Arduino and the Teensy?
The art of getting good answers lies in asking good questions.

thor7

Hi,

sorry for my late answer.

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.

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

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

pylon

Quote
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.


Quote
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.

PaulS

Quote
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.
The art of getting good answers lies in asking good questions.

Go Up