Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: How to share SPI with the Audio optimized SD library ???

  1. #1
    Senior Member
    Join Date
    Aug 2014

    How to share SPI with the Audio optimized SD library ???

    Can I share the SPI (serial peripheral interface) with the Audio library while audio is playing back?

    I am currently using all 3 UART ports, I2C and I2S audio from the Audio library for RAW file playback on an SD card. The goal is to use a SI4430 radio at the same time that Audio is being opened and closed repeatedly.

    Are there examples of how I would read and write from the SPI while the audio library is using the SD card over SPI? (note I am using the optimized teensy SD library for greater speed).

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Yes. All you need to do is use the SPI transaction functions.

    Just use SPI.beginTransaction() before you begin accessing your SPI device, including asserting its chip select. Then when you're done and the chip select is deasserted, call SPI.endTransaction().

    Obviously you should strive to minimize the time between these functions, since you'll have exclusive access to the SPI and the audio lib won't be able to use it. If your transaction lasts too long, you'll glitch the audio.

  3. #3
    Senior Member
    Join Date
    Aug 2014
    I am having trouble with sharing the Low power labs RFM69 radio. I have tried adding SPI transactions to the library manually with no success. I believe it's something to do with both devices using interrupts on the audio and RFM69 to trigger SPI transfers.

    I currently believe the SPI transactions are already setup in the AUDIO library, so I should not have to reconfigure SPI for AUDIO, but maybe lower the speed back down for the RFM69 module. But I think I may be glitching the audio out as you suggested. Any suggestions for how to get two interrupt driven SPI transactions to play nice? I would hope there is enough bandwidth for both devices?

    //#define SD_SPI_SPEED SPISettings(25000000, MSBFIRST, SPI_MODE0)

    //SPISettings settingsRF(10000000, MSBFIRST, SPI_MODE0);
    //10mhz sck max frequency for SX1231 per specification sheet!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts