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

Status
Not open for further replies.

zachtos

Well-known member
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).
 
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.
 
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)
//THIS IS THE TEENSY OPTIMIZED LIBRARY ABOVE

//SPISettings settingsRF(10000000, MSBFIRST, SPI_MODE0);
//10mhz sck max frequency for SX1231 per specification sheet!
 
Status
Not open for further replies.
Back
Top