Home Forums Sparkfun MP3 Shield Library Support Forum SFEMP3Shield works with Arduino Due Reply To: SFEMP3Shield works with Arduino Due


Happy it is working (better…)

“1- Okay, changing USE_ARDUINO_SPI_LIBRARY 1 fixes the problem…”
Sorry I do not think before to tell you about value of USE_ARDUINO_SPI_LIBRARY.
You right, SD card works with a value of zero. But our problem is precisely to put to work TOGETHER several devices using the same SPI interface. SD card, MP3 shield and IR receiver in your case, SD card, MP3 shield and Ethernet in mine.
Setting USE_ARDUINO_SPI_LIBRARY to 1 insure SdFat library use the same SPI library (see #include <SPI.h> at line 27 of Sd2Card.ccp) as SFEMP3Shield library ans Ethernet library. I do not know how you would drive your IR receiver.

“2- I changed SFEMP3Shield::spiTransfer() from …”
See http://http://arduino.cc/en/Reference/DueExtendedSPI : “The parameter SPI_CONTINUE ensures that chip selection is keep active between transfers”
Extended SPI make easier to programmer to manage multiple device, storing parameters as clockDevider, dataMode, bitOrder for each device.
But I did not say you can’t make a version of SFEMP3Shield library without extended SPI capacities! I guess it is possible.
I take that way because Ethernet library for Due use those capacities and I think it is somehow faster.

“3- I now have a new problem…”
I assume you want to say SFEMP3Shield::playMP3() instead of SFEMP3Shield::begin().
Effectively, SFEMP3Shield::Mp3WriteRegister() include a call to refill(), in case it is called during reproduction of music.
But the most important is that you MUST include in the loop() function of your sketch a call to refill(), more precisely a call to SFEMP3Shield::available(). See lines 122 to 127 of example MP#Shield_Library_Demo.ino
Actually, I think you have this line because without it mp3 chip would not last more than 1 second playing!
Did you have this line in your sketch? Are you sure there is not an other process that occupy too much time?
Did your file play entirely with MP#Shield_Library_Demo.ino ?
Did you try with an other file?

“I see that in SFEMP3Shield::refill() you have:…”
Oops! That is right. And in contradiction with what I say at beginning of that: I remember having tried such code, but don’t remember why I let this version.
Let me time to verify.

“Things now appear to work properly”
That means your file plays entirely with that modification?

I am not an expert, I make mistakes, but I am confident that by sharing our knowledge we all progress