Arduino Nano: is SPI supported?

CL22 picture CL22 · Apr 17, 2013 · Viewed 18.1k times · Source

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

Answer

angelatlarge picture angelatlarge · Apr 18, 2013

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.