Arduino Nano: is SPI supported?
Asked Answered
F

3

5

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

Fearfully answered 17/4, 2013 at 9:1 Comment(0)
P
6

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.

Ply answered 18/4, 2013 at 2:36 Comment(1)
This had been true in 2010, but not really an accurate summary by the time in 2013 when you wrote this. Arduino started listing SPI as an official, library-supported function of these pins on the Duemilanove by the end of September 2010, wheras previously they had listed a hardware capability unsupported by software. They appear to have merely failed to update the page for the comparable-function Nano.Fritzie
U
3

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.

Unassailable answered 31/3, 2015 at 15:51 Comment(0)
F
1

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.

Fritzie answered 20/5, 2016 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.