This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Codec TLV320AIC3100 Loopback

Other Parts Discussed in Thread: TLV320AIC3100, TMS320C5533

We are using tlv320aic3100evm-u and codec control software. We required Mic to speaker loopback. We send following commands,

# --------------------------------------------------------------- page 0 is selected
w 30 00 00
# s/w reset
> 01
# PLL_clkin = MCLK,codec_clkin = PLL_CLK
w 30 04 03
# PLL Power up, P = 1, R = 1
> 91
# J = 8
> 08
# D = 0000, D(13:8) = 0
> 00
# D(7:0) = 0
> 00
# mode is i2s,wordlength is 16
w 30 1b 00
# NDAC is powered up and set to 4
w 30 0b 84
# MDAC is powered up and set to 4
> 84
w 30 12 84
> 84
# DOSR = 128, DOSR(9:8) = 0
> 00
# DOSR(7:0) = 128
> 80
# DAC => volume control thru pin disable
w 30 74 00
# DAC => drc disable, th and hy
w 30 44 00
# DAC => 0 db gain left
w 30 41 00
# DAC => 0 db gain right
> 00
# --------------------------------------------------------------- page 3 (touch screen) is selected
# SAR configuration
w 30 00 03
w 30 02 18
w 30 06 80
w 30 03 01
w 30 11 00
w 30 13 10
w 30 03 25
w 30 1d 14 //loopback
# --------------------------------------------------------------- page 1 is selected
w 30 00 01
# De-pop, Power on = 800 ms, Step time = 4 ms
w 30 21 4e
# HPL and HPR powered up
w 30 1f c2
# LDAC routed to HPL, RDAC routed to HPR
w 30 23 44
# HPL unmute and gain 1db
w 30 28 0e
# HPR unmute and gain 1db
> 0e
# No attenuation on HP
w 30 24 00
w 30 25 00

# MIC BIAS = AVDD
w 30 2e 0b
# MICPGA P = MIC 10k
w 30 30 50
# MICPGA M - CM 10k
> 40
# --------------------------------------------------------------- page 0 is selected
w 30 00 00
# select DAC DSP mode 11 & enable adaptive filter
w 30 3c 0b
w 30 00 08
w 30 01 04
w 30 00 00
# POWERUP DAC left and right channels (soft step disable)
w 30 3f d6
# UNMUTE DAC left and right channels
> 00
# POWERUP ADC channel
w 30 51 80
# UNMUTE ADC channel
> 00

w 30 00 01

w 30 23 08
w 30 23 00
w 30 26 00
w 30 27 00

w 30 23 40
w 30 23 AA
w 30 26 80
w 30 27 80

w 30 2a 0d
w 30 2b 0d

w 30 00 01
# Unmute Class-D Left
w 30 2a 1c
# Unmute Class-D Right
w 30 2b 1c
# Power-up Class-D drivers
w 30 20 c6
w 30 24 30
w 30 25 30

But ,it didn't works. please help us.

  • Hi, Mahesh,

    Welcome to E2E and thank you for your interest in our products.

    I will take a look of your commands and I will answer you as soon as possible.

    Thank you.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hi, Mahesh,

    I already tested your script with the EVM. It worked correctly: I could hear audio from the HP output and from the speaker output. Could you describe your problem please?

    Thank you.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hello Luis,
    Thanks ,the script is correct. Actually the problem was in jumper setting. Now I am able to generate loopback.Thanks for your support.
    Now, I have another question. Can we send .wav or .mp3 data to codec directly or do I need to do any settings related to format of data.

    Thanks and Reagards,
    Mahesh Keste.
  • Hello, Mahesh,

    Actually, the EVM is capable to receive .wav or .mp3 data because it has a TAS1020 which can convert the audio stream from USB to I2S.
    The codec needs to receive the data in I2S, Left/right justified or DSP format. Additionally, the data format for all the protocols is 2's complement (signed). The data range is from 0x8000 to 0x7FFF and the mid-range is 0x0000 (for a 16-bit word length).

    I hope this helps you. If you still have questions, please let me know.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hello Luis,

    Thanks. Now ,We are going to use Codec AIC3100 with ATMEL controller ATSAMA5D31. So that can we send .mp3 or .wav formatted data directly to codec through I2S.i.e codec can internally encode/decode data. We don't need to any formatting of data.

    Thanks and Regards,
    Mahesh Keste.
  • Hello Luis,

    We have few questions related to AIC3100,
    1. If sampling rate is 44.1KHz and we want to send 16 bit data. Then what frequency should be required on WCLK,BCLK pin. How we can relate it with with sample rate and number of data bits.
    2.For I2S data, what shold be setting for sampling of data? Should it at positive edge or negative edge or high level of BCLK? We refer TLV320AIC3100 datasheet (page 74 ,section I2S Mode) but it didn't clearify the timing diagram about I2S.
    2.We are going to use Codec AIC3100 with ATMEL controller ATSAMA5D31. We want to send .mp3 or .wav data directly to codec through I2S. So will codec internally encode/decode data? We don't need to do any settings in the codec about it? Can you please confirm this?

    Thanks and Regards,
    Mahesh Keste.
  • Hello, Mahesh,

    1.- The WCLK must be configured with the same frequency as the sampling rate. I mean, if your sampling rate is 44.1kHz, the WCLK frequency must be 44.1kHz too. Regarding the BCLK frequency, it can be calculated as BCLK = WCLK * Word_length * number_of_channels. If you are planning to use 2 channels, BCLK would be BCLK = (44.1kHz)*(16 bits)*(2 channels) = 1.4112 MHz

    2.- Please take a look of the following picture, it explains the I2S protocol.

    3.- Unfortunately, we don't support the ATMEL devices. However, the controller that you're using must be capable to convert the data stream to the I2S protocol. It must respect the I2S conditions (shown in answer 2) and the 2's complement format (signed).

    I hope this helps you. If you still have questions, please let me know.

    Best regards,

    Luis Fernando Rodríguez S.

  • Hello Luis,
    Thanks for your support.

    We set the desired frequency as you mentioned.We done following setting for AIC3100,

    WM8904_Write(pTwid, device, 0x04, 0x03); //pll_clkin=mclk,codec clk in =pll clk
    WM8904_Write(pTwid, device, 0x05, 0x91); // pll powered p=1,r=1
    WM8904_Write(pTwid, device, 0x06, 0x07); // j=7
    WM8904_Write(pTwid, device, 0x07, 0x02); //d=560(0x0230)
    WM8904_Write(pTwid, device, 0x08, 0x30); //d=560
    WM8904_Write(pTwid, device, 0x1b, 0x00); //i2s,16 bits,bclk,wclk input
    WM8904_Write(pTwid, device, 0x0b, 0x85);// ndac=5
    WM8904_Write(pTwid, device, 0x0c, 0x83); //mdac=3
    WM8904_Write(pTwid, device, 0x0d, 0x00); //dosr=128(0x0080)
    WM8904_Write(pTwid, device, 0x0e, 0x80); //dosr=128(0x0080)

    WM8904_Write(pTwid, device, 0x12, 0x85); //adc nadc 5
    WM8904_Write(pTwid, device, 0x13, 0x83); //adc madc 3
    WM8904_Write(pTwid, device, 0x14, 0x80); //adc aosr 128
    WM8904_Write(pTwid, device, 0x3d, 0x04);
    WM8904_Write(pTwid, device, 0x3f, 0xd6);

    //WM8904_Write(pTwid, device, 0x15, 0x80);
    WM8904_Write(pTwid, device, 0x74, 0x00);
    WM8904_Write(pTwid, device, 0x44, 0x00);
    WM8904_Write(pTwid, device, 0x41, 0x00);
    WM8904_Write(pTwid, device, 0x42, 0x00);
    WM8904_Write(pTwid, device, 0x1d, 0x17);
    WM8904_Write(pTwid, device, 0x52, 0x80);
    WM8904_Write(pTwid, device, 0x58, 0x77);
    WM8904_Write(pTwid, device, 0x30, 0x14);

    WM8904_Write(pTwid, device, 0x00, 0x01);
    WM8904_Write(pTwid, device, 0x21, 0x4e);
    WM8904_Write(pTwid, device, 0x1f, 0xc2);
    WM8904_Write(pTwid, device, 0x23, 0x88);
    WM8904_Write(pTwid, device, 0x28, 0x0e);
    WM8904_Write(pTwid, device, 0x29, 0x0e);
    WM8904_Write(pTwid, device, 0x24, 0x00);
    WM8904_Write(pTwid, device, 0x25, 0x00);
    WM8904_Write(pTwid, device, 0x2e, 0x0b);
    WM8904_Write(pTwid, device, 0x30, 0x04);
    WM8904_Write(pTwid, device, 0x31, 0x40); //40//44
    WM8904_Write(pTwid, device, 0x40, 0x0c);

    WM8904_Write(pTwid, device, 0x00, 0x00);
    WM8904_Write(pTwid, device, 0x3c, 0x0b);
    WM8904_Write(pTwid, device, 0x00, 0x08);
    WM8904_Write(pTwid, device, 0x01, 0x04);
    WM8904_Write(pTwid, device, 0x00, 0x00);
    WM8904_Write(pTwid, device, 0x3f, 0xd6);
    WM8904_Write(pTwid, device, 0x40, 0x00);
    WM8904_Write(pTwid, device, 0x51, 0x80);
    WM8904_Write(pTwid, device, 0x52, 0x00);

    // WM8904_Write(pTwid, device, 0x14, 0x00);

    WM8904_Write(pTwid, device, 0x00, 0x01);
    WM8904_Write(pTwid, device, 0x23, 0x40);
    WM8904_Write(pTwid, device, 0x23, 0x44);
    WM8904_Write(pTwid, device, 0x26, 0x80);
    WM8904_Write(pTwid, device, 0x27, 0x80);
    WM8904_Write(pTwid, device, 0x2a, 0x0d);
    WM8904_Write(pTwid, device, 0x2b, 0x0d);
    WM8904_Write(pTwid, device, 0x20, 0xc6);
    WM8904_Write(pTwid, device, 0x24, 0x30);
    WM8904_Write(pTwid, device, 0x25, 0x30);

    WM8904_Write(pTwid, device, 0x00, 0x00);
    WM8904_Write(pTwid, device, 0x41, 0x00);
    WM8904_Write(pTwid, device, 0x42, 0x00);
    WM8904_Write(pTwid, device, 0x44, 0x7f);
    WM8904_Write(pTwid, device, 0x45, 0x00);
    WM8904_Write(pTwid, device, 0x46, 0xe2);

    Please check, if we are missing any settings.

    We are sending audio data from DMA, but we are unable to play data.

    Can we send audio data in polling method. So that I can hear some voice. If for polling method using Atmel functions if we missing timing diagram required for codec. Then it possible that we can hear some noise?

    Thanks and Regards,
    Mahesh Keste.
  • Hello Luis,

    One more question I wanted to ask is shall we use codec in I2S slave mode or in master mode? I mean Bclk and wclk signals should be generated in codec or on controller side?

    Thanks
    Mahesh
  • Hello, Mahesh,

    I already reviewed your register configuration. It seems to be in order, but there are some reserved registers that are being written (Page 1: Registers 0x40, 0x27, 0x2b, 0x20 (bit D6)). Please avoid to write on these registers.

    Have you tried to route the input directly to the output? This path is used to ensure that inputs and outputs are configured correctly and the problem would be on the serial data interface. Additionally, could you provide the MCLK frequency that you're using?

    Finally, regarding your last question, the BCLK and WCLK signals can be configured as outputs or inputs to reach your clock needs. I mean, normally the codec use to be configured as slave when there are several devices that share the same clocks lines from the processor (master). If you're using only one codec and one processor, you can configure the codec as you prefer. You only need to respect the clocks timing.

    Best regards,
    Luis Fernando Rodríguez S.
  • sayname.zipHello Luis,

    Thanks for your great support. I am still having more questions about playing audio

    1. Currently I am not trying for loopback as I am facing some issues with the microphone. So currently concentrating on playing the audio data. As per your suggestion I have removed the code to write those specific registers.

    2. I have done following settings, Sample rate=48KHz, MCLK=12MHZ, BCLK=2x16x48=1.536MHz, WCLK=48KHz and I am generating clocks from codec. With these settings I am playing the attached .wav file. This .wav file has sample rate of 8K and 16-bit PCM sample format. Is it ok to play this file with the settings done above or we need to use sample rate according to this file.

    3. In one of your reply, you have mentioned that data format has to be 2's completement. Then shall I need to convert above .wav files's data to 2's complement data. If yes, then I should be knowing the data format of the file which I would like to play on this codec. Is this understaning right? Any .wav or .mp3 file can not be played as it is (downloading some file from the internet) until it is converted to 2's complement data format. Is this understanding right?

    4. Currently I am not using DMA for playing this file. I am writing in a loop to the I2S data lines. I hope this should be OK.

    5. I am able to hear some tones for this .wav file but not exactly same audio as the .wav file played in some other player. So do you think that I am on right track? Can you please guide what I am missing.

    6. Is there a way by which you can provide us some sample data of audio which can be played with above settings? Some .wav or .mp3 file should be OK. Currently I am able to define an array of 16000 byets in my RAM from where I am transferring data to the I2S in a loop.

    Your help is really appreciated.

    Thanks and Regards,

    Mahesh Keste.

  • Hello, Mahesh,

    There's no problem to play a file with a higher sample frequency. I mean, if the audio file was sampled at 8kHz, there's no problem to use a higher sample frequency such 48kHz. It must not be lower than 8KHz.

    The .wav or .mp3 files must be converted to I2S format before send them to the codec. There's no codec with this capability. So, we use an stereo USB audio interface such the TAS1020b (which is already replaced by the TMS320C5533). We suggest to use an audio interface like this to send the data to the codec.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hello Luis,

    Thanks for the mail.

    Good news is that I could play a .wav file. It was 16 bit PCM encoded .wav file. I copied that file in hex format in the ram in an array. And I transferred that array data one by one over I2S data. So I could hear same contents as of wav file.

    So I2S data format is same as of 16 bit PCM encoded file. Is this understanding correct?

    Moreover I tried playing same file with different sample frequency but I couldn't hear it properly unless if I used same sample freq as of the file which is 8khz. Am I missing something?

    I am going to try to play same file with dma now. Will let you know results.

    Your help is really appreciated.

    Thanks

    Mahesh

    Thanks for the mail.

    Good news is that I could play a .wav file. It was 16 bit PCM encoded .wav file. I copied that file in hex format in the ram in an array. And I transferred that array data one by one over I2S data. So I could hear same contents as of wav file.

    So I2S data format is same as of 16 bit PCM encoded file. Is this understanding correct?

    Moreover I tried playing thisfile

  • Hi, Mahesh,

    I'm glad to read that you could play the .wav file. Actually, the I2S is a specific type of PCM digital audio communication. The PCM format is 2's complement (signed) too. So, there should be no problem to copy it in the RAM.

    Actually, I think that the file must be played at 8kHz. The file was already saved in an array, so probably you must modify the array if you want to use another frequency.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hello Luis,

    Thanks. I am able to play .wav file from ATMEL controller through DMA. Now ,we required to interface single ended mic to codec TLV320AIC3100.I have attached the schematic please check it

    We interfaced single ended MIC to MIC1LM  pin of TLV320AIC3100-EVM. We are able to get loopback from MIC to Speaker. But it will generate lots of noise. I have attached the screenshots of AGC setting.Please check it and let me know if I have missing any settings.

    Thanks and Regards,

    Mahesh Keste.

  • Hello Luis,

    I have one more queries related to this,


    I am connected external MIC MP23AB02B to MIC1LM pin of codec on TLV320AIC3100-EVM and loopback the ADC -DAC. I required to use only MIC1LM pin in our final design so i connected external to EVM.

    I have already attached the screenshot of settings done through control software. I am able to hear audio from MIC to speaker. But i will hear some noise along with actual voice.So

    please check the settings of AGC and let me know if I am missing any settings.

    I required to implement the Filter for ADC. So I used ADC processing block 4. Using TI biquad coefficient calculator i have designed low pass filter with FC=10Hz. I think for this filter ideally all audio frequency should be blocked but still I am able to hear some noise and even noisy loop back from MIC to speaker.Please note that I have designed filter only for ADC.So can you guide me how to design filter for ADC and what setting are required for this?Please provide the any sample code or documents which will help us to design filter.

    Thanks and Regards,
    Mahesh Keste.
  • Hello, Mahesh,

    Please take a look of the following picture. It is a single-ended mic connection to the TLV320AIC3100.

    Additionally, take a look of the following wiki article, it could be helpful: https://e2e.ti.com/support/data_converters/audio_converters/w/design_notes/1088.should-i-connect-a-capacitor-to-a-micbias-pin-what-should-i-do-about-noise

    I already reviewed your AGC settings and it seems to be in order. It is programmed to reach -5.5dB as the output value and mute the device if the noise is below -62dB. Is it the configuration that you need?

    Regarding the sample code about the low-pass filter, please take a look of the following code lines:

    w 30 00 04
    w 30 08 00
    w 30 09 17
    w 30 0a 00
    w 30 0b 17
    w 30 0c 7f
    w 30 0d d0

    It must be configured before the ADC is enabled. These coefficients must be calculated by the TIBQ software: http://www.ti.com/tool/COEFFICIENT-CALC. The GUI calculator is used for the DAC filters.

    I hope this helps you. If you still have questions, please let me know.

    Best regards,

    Luis Fernando Rodríguez S.