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

Thread: How to create a third I2S tx rx channel

  1. #1
    Junior Member
    Join Date
    Sep 2018
    Posts
    17

    How to create a third I2S tx rx channel

    Hi again. Your implementation of quad I2S is slick even if you have to flywire the cpu to to the codecs. Am I correct that the processor used in T3.6 has only 2 full duplex I2S ports. I need to perform some transforms on audio data as I route it here and there. I currently have assigned I2S channels as shown below.

    I2S1 RX Audio from Radio
    I2S1 TX Audio to Radio

    I2S2 TX Audio to Headphones
    I2S2 RX Audio from Ambient Noise Feedback Microphones

    I had planned to use USB Host Audio for the Array Microphone as follows

    USB Host Audio RX from Voice Capture Array Microphone
    USB Host Audio TX Ambient Noise feedback to Capture Array Microphone

    Without USB Host Audio I need to switch to an I2S version of the microphone which means

    I2S3 RX Audio RX from Voice Capture Array Microphone
    I2S3 TX Audio TX Ambient Noise feedback to Capture Array Microphone

    I need to route processed audio among these audio ports. What's the easiest way to add a third full duplex I2S channel? Will the hardware support it?

    I suppose I could attach the radio audio to a DAC and ADC channel thus using the T3.6 as a kind of codec and use the quad for the other routing

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,114
    Sounds like you are thinking of a maximum of two audio channels per I2S channel. But, especially when you are only working with 16bit audio, you might pack up to four 16bit audio words per frame and per channel without changing the sample rate or the bit clock which gives you a total of 8 input and 8 output audio channels.

  3. #3
    Junior Member
    Join Date
    Sep 2018
    Posts
    17
    The I2S spec appears to have limit the data to L/R data at the given sample rate. I agree that the data treated as mono streams does not have to come or go to the same source. The only requirement would be that the two sub channels self sync. Do you know if I2S can support more than L/R?. How would the packing you suggest be implemented. I do know TDM allows more than two channels per sample rate frame but the peripheral chips I'm forced to use don't support it directly. TDM, however would be a good way to interchange multiple channels between several T3.6 modules though I'd have to check to see it using TDM would supersede one of the I2S channels.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,969
    Quote Originally Posted by Kent.Swan View Post
    What's the easiest way to add a third full duplex I2S channel?
    There are no easy ways, only difficult ways. The hardware has only 2 I2S stereo data channels.

    TDM is usually the best way to get more channels.

    https://forum.pjrc.com/threads/41371...l=1#post138705

    Theremingenieur's suggestion to pack more data into the unused bits would probably involve designing digital logic to multiplex the data. It also depends on a BCLK/LRCLK ratio of 64, which we do have for the stereo I2S. But on the quad I2S this ratio is still only 32, so as a first step you'd have to convert that code to a ratio of 64. That has been planned for some time, so if you get that working I hope you'll contribute the changes...


    Quote Originally Posted by Kent.Swan View Post
    Do you know if I2S can support more than L/R?
    I2S is fundamentally 2 channels. The LRCLK is high during the bits for 1 channel and low for the other bits, except for a 1 bit delay (a minor detail).


    TDM, however would be a good way to interchange multiple channels between several T3.6 modules....
    Teensy's TDM support is master mode only.

    A common misunderstanding we get with digital audio questions is lack of considering master versus slave mode. These terms refer to the clocks, not the data. A slave device can be a transmitter. Slave mode merely means it receives the clock from the other side. Nearly all ADC chips are used this way - it gets the clock from Teensy and transmits the data aligned to the clock pulses it receives. Slave mode means receiving the clocks, where the master is in control of the timing and actual sample rate.

    Another important detail, which is purely a software limitation, is the audio library runs at a single sample rate. All parts of the library are synchronous. Normally all the inputs and outputs are master mode, which lets you use multiple I/O and everything runs fully sync'd to Teensy's clock.

    However, if you use the I2S slave feature, which only supports stereo (no 4 channel), the entire audio library will run at the sample rate dictated by the external LRCLK signal. If you try to also use any of the other inputs or outputs, even the built in ADC and DAC, they will try to run sync'd to Teensy's clock. The result is small dropouts or glitches. There is no support for resampling or adapting between different clocks & sample rates.

Posting Permissions

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