Home Forums Sparkfun MP3 Shield Library Support Forum Pin 10 mystery Reply To: Pin 10 mystery

#2636

On the SFE MP3 Shield it IS FREE. But only as an output. It cannot be used as a simple input.

A0,A1,A2,A3,A4,A5,D5 are entirely free. Where D3 and D4 may be used if SJ1 and SJ2 are cut and their cut positions of MIDI and GPIO1 are acceptable for ones application. D1 and D0 can be used if there is no need for Serial, other than Arduino Boot Kernel.

Note: Directly from http://arduino.cc/en/Reference/SPI

Note about Slave Select (SS) pin on AVR based boards
All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.

It is, however, possible to use any pin as the Slave Select (SS) for the devices. For example, the Arduino Ethernet shield uses pin 4 to control the SPI connection to the on-board SD card, and pin 10 to control the connection to the Ethernet controller.

OK, so what does that last part mean… The above assumes you already understand what a slave and master means, and along with the implied orientation. In short the SPI can be either Slave or Master. The SdCard and the VS1053 are Slaves, where the Arduino or the underlying ATmega328 is the Master. The slaves have a dedicated input pin for selecting it, allowing other slaves to exist on the same SPI, so that the Master may select one at a time to talk to.

The Arduino’s CPU (ATmega328) can be configured to be a slave. And when so the SS or pin10 can(must) be used as the select, which is an input. But Arduino’s native Libraries only support the ATmega328 as a Master and not as a Slave. So when the ATmega328’s SPI is used as a Master the SS pin means nothing.

The ATmega328’s method of configuring its SPI between Slave or Master modes is determined by the configured direction of SS or pin 10. So when the SS or pin 10 is configured as an input the ATmega328’s SPI is a slave, which is NOT supported by Arduino’s libraries. Basically the SPI does not work. Since the ATmega328 SCK pin is now an input expecting clock, rather than generating clock towards slave, as when a Master. Hence SS or pin10 must be configured as an Output, if one desires the SPI to work (i.e. as a Master). In which that output can by used for any purpose. By convenience it is often used to drive the enable of the attached slave SPI devices. But it could be any digital output that drives external slaves enables, it does not have to be SS (as it means nothing in master mode). On the SFE MP3 Shield D6, D7 and D8 are used as SPI slave selects of for the SdCard (D8) and VS1053 (D6-commands and D7 for audio Stream data).