Post Go back to editing

ADAU1401 I2S slave

Category: Software
Product Number: ADAU1401
Software Version: Sigma Studio 4.6

Hi,

I am a non engineer,

so I want to make an audio effect using adau1701/1401.

but because there is no long delay available, I want to connect it to teensy via I2S connection,

but I can not found any way to connect it to teensy.

I read many articles on this forum but I didn't understand for the most of it.

I need guidance.

Thank you.

Parents
  • Hello Julius,

    It is an interesting idea to use a Teensy to be a delay line. 

    Using I2S is in and out of this processor is fairly straightforward. The issues you need to be aware of:

    Master Clock. You either need to feed the master clock from the same source as the Teensy is using if the Teensy is a clock master for the I2S. The Master Clock will need to be 256x fs. The easiest thing to do is to run the ADAU1701 as a clock master as long as the Teensy  is able to be a clock slave for I2S. Then master clock is not an issue. I do not know the Teensy so there may be details I am not aware of. 

    I would suggest not running with a sampling rate of more than 48kHz because the transmission line for the clocks do not have to be perfect to work. If you try to run at 192kHz you will most likely have issues and the number of instructions in the DSP will be small. 

    The setup of the part for digital in and out is fairly simple. You have to set the appropriate MP pins for the correct function. 

    You also will need to connect the LRCLK_IN and BCLK_IN over to the LRCLK_OUT and BCLK_OUT pins in hardware outside of the chip. 

    I have attached a project which shows how to send data to the digital serial port and how to receive signals from the serial port.  

    I also suggest you read up on I2S in Wikipedia so it makes more sense to you. 

     ADAU1701 Digital Out with Digital In Loopback test.dspproj

  • Hi Dave,

    I use teensy 4.0.

    and it can be used as i2s sl4ve device (https://www.pjrc.com/teensy/gui/?info=AudioOutputI2Sslave).

    there is no pin to accept the m4ster Clock . . .

    the sample rate would be processed as 44.1Khz (according to Paul, teensy creator).

    I will try to implement your solution and give you the report.

  • Hello Julius,

    Since the Teensy does not need master clock then it is just looking at the bit clock and data to shift in the audio. No problem. That actually makes it easier. 

    Regarding the 44.1kHz sampling rate. The ADAU1701 eval board is stuffed with a 12.288kHz crystal so it can only do 48kHz/96kHz/192kHz sampling rates. You would have to change the crystal to a 11.2896MHz oscillator. 

    If the Teensy is processing at 44.1kHZ then I am not sure how it will deal with it. Depends on the interrupt structure. It might repeat samples from time to time which will be seen as some distortion in an FFT. The oscillator frequencies will be a little off and the filter corners also will be a little off. But it will work and you will get audio. So take this first step then we can work on how to change the 1701 to be running at 44.1kHz.

    Dave T

  • Hi Dave,

    So this is my report.

    I follow your suggestion and tried it .

    there was several result as I change the configuration.

    all the teensy program was I2S-slave-in directly connected to I2S-slave-out. (functioned as pass through connection)

    all the ADAU1401 program is to send 1Khz sine at 24bit/44.1Khz .

    1.  - BCLK out to BCLK in

         - BCLK in to BCLK teensy

         - LRCK out to LRCK in

         - LRCK in to LRCK teensy

         - S_DATA_OUT to RX teensy

         - TX teensy to S_DATA_IN 

    the result is quite bizarre.

    so I change the cable connection a bit.

    2.  - BCLK out to BCLK teensy

         - BCLK teensy to BCLK in

         - LRCK out to LRCK teensy

         - LRCK teensy to LRCK in

         - S_DATA_OUT to RX teensy

         - TX teensy to S_DATA_IN 

    the result is far better, although with slight noise here and there.

    so I tried to fiddle with program configuration

    3. (connection is the same with (2).

    but I change the BCLK polarity and and MSB position to delay 0.

    and the result is quite flawless.

    and I wonder if I use the correct setting?

    note: my test rig is USB soundcard used as oscilloscope , using SCOPE program.

    and here the picture of my experiment.

  • Hello Julius,

    This is a classic sign of signal integrity issues. You probably have high reflections on the clock lines that mess up the timing of the bit clock verses data. You are not running at a high sample rate and your lines between the two boards are quite short so that is good but obviously you still have issues. I also suspect grounding and power issues. You my not have a good ground so there is a lot of digital noise on the ground which will also mess with the thresholds of the digital data. 

    So you may want to try to setup a good ground using the bus bars on the breadboard. Then what also is helpful is to run a ground wire alongside the BCLK, LRCLK and SADATA. Often what I do is use a ribbon cable and make every other wire a ground. So it would go like this:

    1- GND

    2=LRCLK

    3= GND

    4=BCLK

    5=GND

    6=SDATA_IN

    7= GND

    8=SDATA_OUT

    This may help. Also, it can be good to damp down the reflections using a series resistor. I would use one for each of these signals I mentioned.

    Your setup is not correct for I2S but with those settings you compensated for timing issues. The BLCK should be falling edge and you should have 1BCLK delay at the start of the frame. That is the standard for I2S. Your experiments show that it is simply a timing issue which goes back to having good clean edges of the clocks. Reflections in a transmission line will mess up the edges. There will also be a lot of over and undershoot which will throw a lot of noise on the power and ground busses. 

    One test you want to do to see if the data is good. Because, if the timing it off you could miss one bit and be off on level. 

    So setup a sine wave generator in the DSP. Then send it out of the serial port. The internal oscillator is a full scale 24 bit signal. If it clips in the Teesy then there is an issue with the data pickup. Then turn the data around and send it back to the DSP. Then on the inside of the DSP you send the incoming signal directly to a meter and measure it. It should read -3dB which is a full scale signal. This is a good confirmation that all the data is going out and coming back in correctly. If it is clipped or 6dB low then you are off by one bit clock cycle. 

    Dave T

  • Hi Dave, so I give it a try.

    I use the ribbon cable as you suggested, but the result was just as bizarre as the first try.

    and I don't see any way to fix it. probably because the cable was too long?

    So I revert to using the single cable and tried to make the cable didn't touch each other.

    and yeah, the sine wave was clean.

    But I have yet to try audio source.

Reply
  • Hi Dave, so I give it a try.

    I use the ribbon cable as you suggested, but the result was just as bizarre as the first try.

    and I don't see any way to fix it. probably because the cable was too long?

    So I revert to using the single cable and tried to make the cable didn't touch each other.

    and yeah, the sine wave was clean.

    But I have yet to try audio source.

Children
  • Hello Julius,

    I don't think the ribbons were too long for lower sampler rates. But it was longer than the ones you were using. I think one of the factors here is ground and power connections. It looks like you are taking power from two different USB sources. Not sure if it is two computers or two different power supplies. But couple that with the fact that power and ground are only coming from a couple of wires over to the 1401 board then the ground between the 1401 board and the Teensy board is probably only one wire will make the ground not very good. Then in addition, many USB ports are not very well wired and usually ground does not go directly to ground but through ferrite beads or common mode chokes. This all can create a lot of high frequency noise on the ground for the parts. 

    So once you get your basic design worked out, I suggest you design a PCB to hold both of these modules and power it up from a good power source rather than the USB ports. 

    But it seems you have it basically working now which is good. 

    Dave T

  • Hi Dave,

    I use the voltage from the USBi and it was 3.3v. I missed the obvious. so I moved it to teensy 5V supply and the audio is clean.

    the connection work.

    here the sample of using adau1701 and teensy as reverb.

    problem solved!

    Thank you for the help, Dave.

    much appreciated.

    Best regards.

    Julius.

  • Hello Julius,

    Sounds great!

    Glad you figured it out. It always seems so simple once you find the problem. 

    Dave T