Author Topic: I2S  (Read 5393 times)

0 Members and 1 Guest are viewing this topic.

Offline wiss

  • Frequent Contributor
  • **
  • Posts: 485
  • Country: ch
I2S
« on: January 26, 2014, 04:15:30 pm »
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)
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2321
  • Country: de
    • Frank Buss
Re: I2S
« Reply #1 on: January 26, 2014, 06:27:06 pm »
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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline wiss

  • Frequent Contributor
  • **
  • Posts: 485
  • Country: ch
Re: I2S
« Reply #2 on: January 26, 2014, 07:00:25 pm »
I think I've figured that SPI can sortofmaybe emulate I2S, but this would probably require lots of CPU-time?
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 1636
  • Country: gb
  • Test instrument designer/maker G1YWC.
    • Electron Plus
Re: I2S
« Reply #3 on: January 26, 2014, 07:38:03 pm »
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).
https://electron.plus Power Analysers, VI Signature Testers, Voltage References.
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2321
  • Country: de
    • Frank Buss
Re: I2S
« Reply #4 on: January 26, 2014, 08:11:03 pm »
I think I've figured that SPI can sortofmaybe emulate I2S, but this would probably require lots of CPU-time?
Why 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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 1636
  • Country: gb
  • Test instrument designer/maker G1YWC.
    • Electron Plus
Re: I2S
« Reply #5 on: January 27, 2014, 01:31:42 am »
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.





https://electron.plus Power Analysers, VI Signature Testers, Voltage References.
 

Offline wiss

  • Frequent Contributor
  • **
  • Posts: 485
  • Country: ch
Re: I2S
« Reply #6 on: January 27, 2014, 02:19:27 pm »
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?
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 1636
  • Country: gb
  • Test instrument designer/maker G1YWC.
    • Electron Plus
Re: I2S
« Reply #7 on: January 27, 2014, 03:04:59 pm »
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.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 12136
  • Country: gb
    • Mike's Electric Stuff
Re: I2S
« Reply #8 on: January 27, 2014, 03:13:51 pm »
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.

 
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline wiss

  • Frequent Contributor
  • **
  • Posts: 485
  • Country: ch
Re: I2S
« Reply #9 on: January 27, 2014, 04:52:43 pm »
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 things  :D but 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!  :rant:
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2321
  • Country: de
    • Frank Buss
Re: I2S
« Reply #10 on: January 27, 2014, 05:09:57 pm »
It's easy with the right microcontroller :) For example I've done this with this dev kit with an external codec: http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF252419 There 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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf