Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arduino Nano: is SPI supported?

Tags:

arduino

spi

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

like image 221
CL22 Avatar asked Apr 17 '13 09:04

CL22


2 Answers

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.

like image 164
angelatlarge Avatar answered Sep 24 '22 01:09

angelatlarge


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.

like image 21
CharlieB Avatar answered Sep 25 '22 01:09

CharlieB