I2S - Page 1
Forum section: electronics / beginners

author: wiss
author_rank: Frequent Contributor
timestamp: January 26, 2014, 04:15:30 pm
content: The I2S-protocol sems very common on audio-dac/adc's, how would one comunicate with pair of pcmxxxx-adc/dac from a microcontroller which lack built-in I2S? (tms320f28 for example)

author: FrankBuss
author_rank: Unknown
timestamp: January 26, 2014, 06:27:06 pm
content: You could try SPI, if it has a FIFO and allows continuous transfer. A problem could be to flip the frame signal in sync exactly after each transmitted channel word.

author: wiss
author_rank: Frequent Contributor
timestamp: January 26, 2014, 07:00:25 pm
content: I think I've figured that SPI can sortofmaybe emulate I2S, but this would probably require lots of CPU-time?

author: fcb
author_rank: Super Contributor
timestamp: January 26, 2014, 07:38:03 pm
content: I've used SPI to generate I2S before. It wasn't very difficult as I recall (I was using a dspic without the DCI module, but it did have a nice SPI module).

author: FrankBuss
author_rank: Unknown
timestamp: January 26, 2014, 08:11:03 pm
content: Quote from: wiss on January 26, 2014, 07:00:25 pmWhy does it require lots of CPU time? Usually you can configure your SPI module for MSB or LSB, so no need to bit-swap. Left/right adjustment should be fast, too. The only difficulty would be to flip the frame (ws) signal at the right time. But if interrupt latency is low, and you can time exactly when a new word is sent, you can start a timer to raise another interrupt when the ws signal has to be flipped. The CPU would be idle most of the time, or you could implement your audio processing in the main task, with software FIFOs to send/receive the data over I2S.Another trick would be to use a second SPI module and initialize it a bit later, then using MOSI for ws, and sending 0xffffff and 0x000000. Then you need just at startup one exact delay and don't have to care about interrupt latency.

author: fcb
author_rank: Super Contributor
timestamp: January 27, 2014, 01:31:42 am
content: I also did a design using a 74HC393 to generate the I2S clocks, then an SPI module to create the data stream:12.288MHz crystal on the microcontroller, tapped off to feed the CK on one half of the 74HC393 (the two halves were cascaded).Then tapped off the 3.072MHz (BCK) and 48KHz (LRCK) for the converter. The BCK and LRCK also fed to the SPI module.Depending on the DAC, the MCK can be 12.288MHz (256fs) or 6.144MHz (128fs), be careful tapping the crystal oscillator (that you don't kill it) - I've done it in commercial designs a few times (running a dsPIC and wolfson DAC off the same crystal) with success, but you might want to buffer things.

author: wiss
author_rank: Frequent Contributor
timestamp: January 27, 2014, 02:19:27 pm
content: Thanks.So, if my dsp only have one SPI I can only drive one dac/adc at a time? (I would like to have 1 adc and 2 dacs run simultaniously)Are there any SPI->I2S chips? Would it be messy to build a parallel->I2S? say 8 data-lines and 4 data-address for one stereo-24bit sample frame?

author: fcb
author_rank: Super Contributor
timestamp: January 27, 2014, 03:04:59 pm
content: You've got two SPI's on the TI part you have mentioned.I would build a some logic (see my earlier post) to generate the basic timing infrastructure for the I2S. Then feed this to both SPI modules on your DSP.This should give you both DAC's at least, and if your clever then you can also feed the same I2S to the ADC's and get two ADC's also.I certainly wouldn't bother building a PISO at this stage.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 27, 2014, 03:13:51 pm
content: You can sometimes accurately do I2S with a combination of PWM (for LRCLK) and SPI - depends a lot on the details of the SPI implementation.Some SPI ports (e.g. on PIC32MX) have specific I2S mode.If you're just driving a single, known, DAC, then you can often bend the I2S spec significantly (e.g. not supplying continuous clock), and some DACs have a DSP mode which has easier timing requirements and can easily be driven from SPI.

author: wiss
author_rank: Frequent Contributor
timestamp: January 27, 2014, 04:52:43 pm
content: Oki, Thanks!I have not done MCU's since high-school more than 20 years ago (68705).And when I ws in my teens I read about the tms320 and thought it was a very cool device so I just ordered a LAUNCHXL (tms320f28027) to use for several toy projects. I also took a adc/dac each, some PCMxxxx, at the time I had not realized that I2S and I2C are two very different thingsbut the PCM's were only 2:50 eur each so not a major investment and my primary purpose is something else.I'm pretty surprised that it seems to be so difficult to interface a DSC that you can buy (for cheap) to a bunch of adc/dac's, all the cheap (audio-) adc/dac's talk I2S and all DSC's talk SPI... I want adc/dac's that talk SPI!

author: FrankBuss
author_rank: Unknown
timestamp: January 27, 2014, 05:09:57 pm
content: It's easy with the right microcontrollerFor example I've done this with this dev kit with an external codec:http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF252419There are even example programs how to use the I2S module with the on-board components (I2S microphone and I2S DAC). But Mike's idea with the PWM for ws sounds neat, too, should be possible to do it with your board.