Arduino Uno Slave

Hey Guys,

So I'm trying to switch one of my test setups from another board over to an Arduino Uno. I had a couple of questions. I would appreciate the help.

  1. Can I make the Arduino Uno act as a slave to another device thats not an Uno.
  2. I read that the SPI does not support slave mode on the SPI bus, so does that mean the Arduino can only be a master and not a slave. The only case I've seen of an arduino be a slave is when its connected to another arduino.

To add some insight. I'm hoping my connection to look like the following :

PC <--(TTL converter [ttl3usb9m-ls])--> Arduino <--(I want to use SPI connection and have my device as the Master and the Arduino as the Slave)--> My device <--(Ethernet)--> PC(Back To)

Thanks,

  • K. Somani
  1. Can I make the Arduino Uno act as a slave to another device thats not an Uno.

Maybe. USB slave? I2C slave? SPI slave?

  1. I read that the SPI does not support slave mode on the SPI bus, so does that mean the Arduino can only be a master and not a slave.

The Arduino can be a slave or a master, depending on the state of pin 10 in output mode.

If your Arduino is also driving an Ethernet shield, as an SPI master, then acting a slave too could be tricky.

  1. I read that the SPI does not support slave mode on the SPI bus, so does that mean the Arduino can only be a master and not a slave.

The SPI library (part of the IDE) does not support the slave mode directly although you still can use the library you just have to initialize the hardware by direct register manipulations.

Thanks again for the replies I do appreciate it.

Another question I have is:

Arduino <--(SPI)--> My device

Do you have any recommendations on how I should go about making the Uno a slave to my device?

I do apologize for my poor questioning skills.
Regards,

  • K. Somani

Nick Gammon's SPI page... Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino

Do you have any recommendations on how I should go about making the Uno a slave to my device?

This might be the time where you should tell us more about your "device". On what processor is it based? What voltage level does it have? What SPI speeds does it support?

Sorry about that guys.

Thanks again for the help.

So my device processor is PIC32MZ2048EFM100-x/PT.
The voltage level it is 3.3V and the speed I need to support is 13 MHz.

13MHz is kind of fast, even for SPI. Usually it's closer to 2MHz. Is that the processor speed or the actual SPI bit rate?

I believe its bit rate.

Well I'm looking for an SPI speed of 13 MHz. I also noticed in the link someone attached above that the setup is to connect an arduino to another arduino. Is it possible for me to apply the same principle but with my device.

Yes, of course. There's no rule that says Arduinos are only allowed to talk to other Arduinos. It would be a pretty boring world if that was the case.

It's just that 13MHz SPI is probably too fast for a 16MHz Arduino. You might have better luck with a faster Arduino such as a Due or Teensy.

So I should be able to use that link and work through it with my device. That's good news.
Could you explain to me why I can't use the arduino uno. I mean 16MHz is within my range. Are there any benefits of using a Due or a Teensy.

Thanks.

16MHz is the processor speed. That means it can't react to anything in any way if it appears and disappears in less than a 16-millionth of a second.

Normally for SPI communication, you get a "clock" signal which says "look at the data line NOW" and then you look at the data pin to see if you are receiving a one or a zero. The key part is the "and then". That takes time. With a 16MHz processor, it will take two processor cycles to say "and" and "then". So that means you can't detect any incoming signal faster than 8MHz.

Now that's not entirely true - the Arduino chip has specialised hardware which does the SPI without bothering the main processor. But 8MHz is as fast as it will go. 4MHz is the default transmission speed.

It may work, the receiver may be able to decode 13MHz, but I don't expect that it will work reliably.

What would be the benefits and disadvantages between the Due & Teensy?
Do you have any other suggestions?

Thanks.

What would be the benefits and disadvantages between the Due & Teensy?

Clearly, the benefits are faster processor speeds. Clearly, the disadvantages are that you don't have either one and appear to be unwilling to get either one.

Do you have any other suggestions?

Yes. Get another PIC and go bother that forum.

Sorry.

Thanks for the help.

Now that's not entirely true - the Arduino chip has specialised hardware which does the SPI without bothering the main processor. But 8MHz is as fast as it will go. 4MHz is the default transmission speed.

8MHz is max speed for SPI master, for slave mode it's 4MHz.

Don't forget that the processor does not only have to shift the bits out it also has to provide the information that should be sent. So if one byte is sent an interrupt happens and the next byte has to be written to the SPI register. The interrupt needs several clock cycles so at 4MHz you have no time for any calculations you can only send simple informations.

The Due is not able to be an SPI slave to my knowledge.