Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #2902

    I want to add a device using the SPI bus. I’m worried about two things:

    1. The USE_MP3_INTx as the refill means. I can’t find the ISR code to see if I would need to gracefully terminate operations if the new SPI device was currently in use before letting the ISR run.

    2. I need to use SPI_MODE3 for the added device, and I’m not sure what transmission mode the MP3 player is using so I can switch it back to it.

    Any one have any insights? Michael Flaga? 😉


    There is no need to gracefully terminate SPI transfers, as they are not running in the background, like DMA transfers. Rather the ISR runs in the foreground until completion. They are in while loops.

    The ISR is bound within the attachInterrupt(MP3_DREQINT, refill, RISING); function in the SFEMP3Shield::enableRefill() function.

    When using the SPI ensure it is properly configured prior to using it. Don’t assume it is the way your code last left it. The SdCard and SFEMP3 libraries both when asserting the chip selects configure the SPI correspondingly. Overwriting what ever its prior state, as used by other code. This provides compatibility with other libraries using the SPI. Where the other libraries should do the same. Otherwise they would mess each other up. Yes, it may appear inefficient, but its compatible.

    Note: I see that the SdCard recently added SetBitOrder. the MP3 does not. So that could be an issue, if different.

    You could optionally wrap your code between MP3player.pauseDataStream() and MP3player.resumeDataStream() functions. However, this should no longer be needed.


    Thanks Michael.

    As of now, I have all three devices using SPI achieving initialization success intermittently. Sometimes the SD card (and everything else) fails to initialize due to probable SPI problems. I get this error code when it fails:

    Free RAM = 325
    Can’t access SD card. Do not reformat.
    No card, wrong chip select pin, or SPI problem?
    SD errorCode: 0X1,0XFF

    I cannot find SD errorCode 0xFF anywhere. Do you know where this comes from? Like I said, sometimes it doesn’t encounter this problem and everything can initialize and work together. I’m using SPI MODE3 for when my added SPI device is slave selected. It uses the same bitOrder(MSBFIRST) as the SDcard library. Any help is appreciated!


    That is annoying. I experience the same problem occasionally. It seams to come and go on its own. I have to believe it is a problem un-related to the SFEMP3Shield library itself. As it occurs without it. I am suspicious that it may be an electrical issue, like a capacitance or race issue on the start up of the SdCard. At times I have seen it help to stuff another card into Arduino and it works. Where sometimes sticking the afflicted card into a Laptop then reading it and then back into the Arduino sometimes cures the problem, not always. Where my initial thought may be wear and tear or corrosion on the SdCard connector.

    Let me know of any progress. We may need to advance it to SdCard author.


    If I simply unplug the Arduino USB and reconnect it to the PC enough times and I can eventually get around it. Sounds like a race condition to me too. I just didn’t start seeing it until I decided to add an LCD screen to the SPI, I was convinced I messed something up in the code. Glad to know it’s an existing behavior, I guess.

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