Pregunta

Can SPI hardware on the Arduino Nano be used?

On the Nano page it says:

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

Yet there is an SPI library.

Please can someone explain this contradiction? I think, either

  • The nano page is out of date
  • SPI library is unsupported for the Nano SPI hardware but is supported on other boards
  • SPI library is implemented for the Nano in software only

Which is it?

Thanks

¿Fue útil?

Solución

The correct answer is "some combination of the above":

  • Arduino Nano is based on the ATmega168/328 chip, which does support SPI in hardware.
  • The SPI library only supports hardware SPI (regardless of the Arduino model). Note that you could bitbang (relatively) slow SPI without any problems, this would be a relatively easy software implementation.
  • The status of SPI library should be considered same as the status of the Wire library: not part of core Arduino services (in contrast to PWM, ADC, and digital GPIO), but widely supported nonetheless.

So perhaps the closest answer in your multiple-choice question is "out of date". The status of SPI should look the same as the status of I2C.

Otros consejos

This should be a comment but I haven't the rep.

As angelatlarge said, the SPI library is as supported for the Nano as it is for any of the other Arduinos. Except:

The Nano (like all Arduinos) has an LED attached to digital pin 13. Since, for the Nano, pin 13 is also SCLK for SPI, you may well run into trouble with high baud rates. If this is a problem for you, try removing the LED.

From the Nano's page: Source

...

  • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

  • LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

The Nano's product page is out of date, but it has the same hardware and software SPI support as the other ATmega168/ATmega328p-based Arduinos.

Some archaeology in the wayback machine reveals that the functionally comparable Duemilanove's product page was changed from a hardware-but-not-software mention to a mention of SPI library support between September 15th and 26th of 2010. When the Uno came out, its product page was based on the then-current state of the Duemilanvoe's, so it has always claimed support.

A corresponding update should have been made to the Nano page, but this appears to have been overlooked.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top