3
\$\begingroup\$

Is it possible to switch two master SPI lines using Quad 2:1 multiplexer like (74HC257)? I want my two Master devices to access a single SPI slave (Flash). Please see attached schematics. SPI speed is 4MHz.

The reason for this is that, I have an MP3 module (master2) which already has a flash that I want my MCU (master1) to access the data from. I don't have control on SPI lines of MP3 (Master2).

two SPI master

\$\endgroup\$
1
  • \$\begingroup\$ Do you have to use Flash? There are dual port RAM and EEPROMS available \$\endgroup\$
    – crasic
    Sep 2, 2015 at 7:37

3 Answers 3

1
\$\begingroup\$

I'm assuming that you have no control over the functionality for the MP3 master (i. e. can't change its firmware). When you switch the mux away from the MP3 master, it has no way to know this and may try to access the flash anyway, getting garbage (or all 0/1) responses and do who-knows-what.

SPI, per spec, has no kind of multi-master arbitration.

About the only way to make this work is if your master can pause (stop the clock to) or hold in reset or power-down the MP3 master while you have control of the flash. BTW, I'm only guessing that it might work to stop the clock. If the MP3 master has any kind of dynamic memory, it may not react well to losing its clock.

Also, when taking control of the SPI, you need to make sure the MP3 master is not in the middle of talking to the flash.

All told, what you propose will be difficult at best.

\$\endgroup\$
1
  • \$\begingroup\$ yes I don't have firmware controls over the MP3 but I know when the MP3 master do something on the flash.Its when I only send a command to it. I am much worried about the MUX speed. Can it switch signal of 4MHz? \$\endgroup\$
    – Edmon
    Sep 4, 2015 at 6:38
0
\$\begingroup\$

You may run into trouble running at 4MHz through a 74HC257. You should look at the rise-times in the datasheet. Note that these are voltage dependent.

You might also consider a scheme where you use the slave select pin to switch channels. Something like a MC14551B could work.

\$\endgroup\$
0
\$\begingroup\$

All analogue switches have Cd and Cs specifications, they will limit the bandwidth of the switched signals. Some switches designed to switch high speed signs. So, just check the data sheet.

The big problem is you have no control to the firmware, so directly connect the two output line (CS, MOSI) is dangerous, they may output opposite level at the same time, that will short the power supply. Certainly, you can turn off one completely when another is on.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.