Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2635
    Anonymous
    Inactive

    Hi, the shield and libraries have been working well so far…

    I just have one issue which I posted about on sparkfun. I can’t figure out if pin 10 is actually free or not. When I connect an LED to pin 10 it lights up (fully).

    So I did a test – I set pin 10 as an output at the start, and run… after this line of code:

    if(!sd.begin(SD_SEL, SPI_HALF_SPEED)) sd.initErrorHalt();

    I do a digitalRead() on pin 10 and it’s 1.

    Is it ok for me to set to LOW after that point and use it for my own use?

     

     

    #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).

     

    #2638
    Anonymous
    Inactive

    Wow, thanks for this detailed response. I did take a microprocessor class in college… but that was 20 years ago. So a lot of what you’re saying looks familiar but still pretty fuzzy. If I need to really understand anything, I’ll read up. But it sounds like I can use pin 10 as an output… which is what I need. I’m still a little concerned that the library code lit up an LED on pin 10 however.

     

    #2639

    yes, you can use D10 as an output.

    It light up the LED, as your digitalread(D10) came back with a one. I am sure that the spi.begin() in the library initializes the SS (or D10) as an output and likely as 1, driving your LED.

    #2666
    Anonymous
    Inactive

    Michael P, do you have any insights into how to change the Atmega328’s MOSI pin to the SD card unit from Pin 11 to Pin 10? I can’t find the SdFat’s Pin assignment for the MISO signal.. I understand I would have to add a wire to do this, I just can’t find the code to change.

    (Ardunio Uno Rev3 with the mp3 shield)

     

    Thanks

    #2668

    Could you explain your motive, to provide insight?

    Note the SPI pins MISO, MOSI and SCK are hardware wired to these pins on the Arduino/ATmega328. So they are not movable in software or configuration. And are shared on the SFEMP3Shield by both the VS1053 and SdCard. If you want to either of these pins to a different position on the Shield connection, you can use the method displayed in this video; Hot Wire D5 and D7 pins on the SFEMP3Shield it will work just the same.

    Where I am stumped as to why you would want to move them on the SdCard, as the Shields are lined up correctly to begin with, unless you are using a break out. Which then should connect directly to original hard SPI pins.

    Also note that the on the UNO, Duemilanove pins 10,11 and 12 are tied to the ICS connectors pins. And the Leonardo no longer has the SPI pins on 10-12.

    #2808
    Anonymous
    Inactive

    My motive here is to make use of one of the ATMega328’s hardware timers, either Timer1 (disabling pins 9 & 10) or Timer2 (disabling pins 3 & 11). Based on what you have said above, it sounds like pin 11 (MOSI) is hardwired and can’t be moved. If this is the case, then I should be able to re-assign the SD-Chip Select from pin 9 to something else using the same method in your demo video, so I can make use of an interrupt service routine that uses Timer1.

    I guess my next question would be, do you expect the MP3 playback to be impacted by running a quick and simple ISR on the Arduino every 2 miliseconds?

    #2811

    to move the SD Card’s chip select change SFEMP3ShieldConfig.h line 168 to the pin of your choice. Or create a #ifdef to match your circuit.

    Whereas, to use other timers does not necessarily prohibit the use of their associated pins for GPIO. The pins are free for other use, unless the timer is configured to be used as its timer function e.g. Generate either a Output Compare or PWM or Input Capture.

    Note that the example libraries behavior can be configured to use Timer1 library, in place of Interrupt’s, without changing the pins. by changing SFEMP3ShieldConfig.h line 195

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.