So I currently have a large rgb led screen project where there are multiple ATmega328's connected to each other via SPI. I have 1 master, and 3 slaves. What I want to do is this:
Send data from the master to the slaves via SPI, and once the data has been received, flip the slave chips over to master mode so they can shift out the received data to the shift registers at the 4MHz SPI speeds. However my problem comes in with isolating the 3 slave chips from the main SPI bus. I want to send out the data (on all 3 chips) at the same time to the shift registers, however because the SPI bus is shared between the devices I would get data contention issues.
I had previously tried using a NPN/PNP transistor combination to allow for a digitally controlled inline switch on the SCK, MOSI, MISO, and SS lines, but the problem is it is unidirectional, which is unfavorable in a data line that has to communicate in both directions. What I really need is a bidirectional, digitally controlled, fast turn on/off time (less than 10uS if possible), inline switch. I've looked at triacs, two mosfets connected common source, etc and they are all either too complicated to implement or too slow. Any ideas??
Does each slave need it's own address (CS) on the SPI buss? That is does the master send out the data to each slave individually or do they receive the same data at the same time and each slave figures out what it has to do with the data by sorting it out?
Even though the SPI has that speed can the master actually process the needed data for all 3 slaves at that rate?
Maybe a benchmark on what the master can actually output.
As a side note the 328 can use it's usart hardware in spi mode but that would require some rethinking on another level.
Thanks so much for the replys everyone! I'm sorry I hadn't checked up on this recently...I've been quite busy with life the past two weeks. Anyways, that buffer idea actually sounds like it would work quite well!! I'm certainly going to be checking that out in-depth. Hopefully it can keep up with the data speeds, but I get the feeling it will. I haven't checked up on the datasheet yet.
As for the comment on how much data the master can send out, I decided on using a Raspberry Pi as my "brains" for the project, so the 700 Mhz processor takes care of the data cap. All I am really worried about is how much data the '328 can process and am designing my project under those limits.
codex653:
I had previously tried using a NPN/PNP transistor combination to allow for a digitally controlled inline switch on the SCK, MOSI, MISO, and SS lines, but the problem is it is unidirectional, which is unfavorable in a data line that has to communicate in both directions. What I really need is a bidirectional, digitally controlled, fast turn on/off time (less than 10uS if possible), inline switch. I've looked at triacs, two mosfets connected common source, etc and they are all either too complicated to implement or too slow. Any ideas??
None of those methods make sense for switching a logic signal. Logic signals are
switched by logic gates, such as input selectors, tri-state bus drivers, simple AND gates
even. For bi-directional switching tri-state drivers, analog switches and open-collector
gates are normally chosen. 10ns is the sort of switching speed to expect, 10us is not a
problem.
I think you were just in need of a bus architecture.
Wouldn't you be able to have two transistors 'pointing' opposite ways on one line, so when receiving it runs through the left transistor and when sending it runs a long the right, kind of thing. Either that or if you want it to just not receive you put a split in again with a diode on the right and a transistor on the left, that way you can switch off receiving and have sending pass through reguardless. Just a thought.
codex653:
Send data from the master to the slaves via SPI, and once the data has been received, flip the slave chips over to master mode so they can shift out the received data to the shift registers at the 4MHz SPI speeds. However my problem comes in with isolating the 3 slave chips from the main SPI bus. I want to send out the data (on all 3 chips) at the same time to the shift registers, however because the SPI bus is shared between the devices I would get data contention issues.
Connect the shift registers to pins 0/1/4 and use the USART in SPI mode to talk to them
(the Mega328 actually has two hardware SPI units!)