TLV320AIC3104: Recording sine waves at different sampling rates is problematic

Part Number: TLV320AIC3104

Tool/software:

Hello, something went wrong when I was recording the audio. I recorded 8k sample rate audio and 16k sample rate waveform as shown below. Why is the recorded waveform not smooth, what is the problem?

This is the command I recorded,`arecord -D hw:0,0 -d 10 -f cd -r 48000 -c 2 -t wav 48yy.wav`.

 

This is the register value when I recorded it,I recorded 16k samples.

i2cdump -y -f 0 0x18

No size specified (using byte-data access)

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef

00: 00 00 44 91 60 00 00 0a 00 00 00 c1 00 00 00 26    ..D?`..?...?...&

10: 14 0f f0 04 78 78 7c 78 78 06 00 fe 00 00 fe 00    ????xx|xx?.?..?.

20: 00 00 00 00 cc 20 10 00 40 00 00 80 80 00 80 00    ....? ?.@..??.?.

30: 00 00 00 0f 00 00 8c 00 00 8c 0c 00 80 00 00 00    ...?..?..??.?...

40: 00 0f 00 00 8b 00 00 8c 0c 00 00 00 00 00 00 00    .?..?..??.......

50: 00 80 00 00 00 00 0b 00 00 88 00 00 88 08 16 00    .?....?..?..???.

60: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........

70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

80: 00 00 44 91 60 00 00 0a 00 00 00 01 00 00 00 26    ..D?`..?...?...&

90: 14 0f f0 04 78 78 7c 78 78 06 00 fe 00 00 fe 00    ????xx|xx?.?..?.

a0: 00 00 00 00 cc 20 10 00 40 00 00 80 80 00 80 00    ....? ?.@..??.?.

b0: 00 00 00 0f 00 00 8c 00 00 8c 0c 00 80 00 00 00    ...?..?..??.?...

c0: 00 0f 00 00 8b 00 00 8c 0c 00 00 00 00 00 00 00    .?..?..??.......

d0: 00 80 00 00 00 00 0b 00 00 88 00 00 88 08 16 00    .?....?..?..???.

e0: 00 00 00 00 00 00 a2 00 00 00 00 00 00 00 00 00    ......?.........

f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

 

 

My device tree:

sound {

compatible = "simple-audio-card";

simple-audio-card,name = "tlv320aic3104";

simple-audio-card,format = "i2s";

simple-audio-card,mclk-fs = <256>;

simple-audio-card,bitclock-master = <&dailink0_master>;

simple-audio-card,frame-master = <&dailink0_master>;

simple-audio-card,widgets =

"Microphone", "Microphone Jack",

"Headphone", "Headphone Jack",

"Speaker", "External Speaker",

"Line", "Line Out",

"Line", "Line In";

,routing =

"MIC_IN", "Microphone Jack",

"Headphone Jack", "HP_OUT",

"LINE1L", "Line In",

"LINE1R", "Line In",

"Headphone Jack", "RLOUT",

"Headphone Jack", "LLOUT";

 

dailink0_master:simple-audio-card,cpu {

sound-dai = <&sai1 0>;

};

 

simple-audio-card,codec {

sound-dai = <&codec 0>;

/* clocks = <&clks IMX6UL_CLK_SAI1>; */

};

};

&clks {

assigned-clocks = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;

/* assigned-clock-rates = <1179648000>; */

assigned-clock-rates = <786432000>;

/* assigned-clock-rates = <705600000>; */

/* assigned-clock-rates = <153600000>; */

};

&sai1 {

#sound-dai-cells = <0>;

pinctrl-names = "default";

pinctrl-0 = <&pinctrl_sai1>;

assigned-clocks = <&clks IMX6UL_CLK_SAI1_SEL>,

  <&clks IMX6UL_CLK_SAI1>;

assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;

/* assigned-clock-rates = <2>, <12288000>; */

assigned-clock-rates = <2>, <24576000>;

// assigned-clock-rates = <2>, <28224000>;

status = "okay";

};

Good luck

  • Hi,

    I think there's a mismatch here in sampling rates. Your command calls for 48000 sampling but your waveforms are recorded with 8k, 16k, and 32k sampling. This mismatch can result in abnormalities and distortions in the resulting signal.

    Best regards,
    Jeff McPherson

  • Hi,

    Thank you for your reply. My command uses 48k as an example, and mine uses the following three waveforms recorded with sampling rate of 8000, 16000 and 32000 respectively. I found that the waveforms these three waveforms are very similar in that almost the adjacent sample points appear in pairs. The 48k sampling rate waveform is so bad that I didn't even put it in.

    Best regards.

  • Hi,

    Let me try to recreate this on a test board. I'm not very familiar with device tree settings, so could you clarify for me what your clock frequencies are and if you are in slave or master mode?

    Thanks,
    Jeff McPherson

  • Hi,

    I set Page 0, Register 102 to 0xA2, which is bit clock.

    The main frequency of my cpu is 786432000 Hz, and the corresponding sai interface of i2s uses 24576000Hz. I also don't know much about the required master-slave mode, I use Linux 4.19.35_1.1.0 kernel, after setting the audio channel, I need to use i2c to set Register 102 to 0xA2. Wonder why it's not set automatically.

    Best regards.

  • Hi,

    After a bit of testing I'm confident this is an issue with the clock tree set up. I can provide settings but need some info:

    First reread section 10.3.3.1 in the data sheet

    Confirm that you want BCLK = 24.576MHz, FSYNC = 48kHz?

    Since you want Register 102 = 0xA2, you want BCLK as the CLKDIV and PLL input?

    Are you trying to use the PLL? Given that 24.576MHz/48kHz = 256, the easiest set up is to use the CLKDIV path instead of PLL.

    Best regards,
    Jeff McPherson

  • Hi Jeff,

    Thank you for your help.

    Yes, I do need BCLK = 24.576MHz and FSYNC = 48kHz.

    Yes, I want to use BCLK as the CLKDIV and PLL input.

    I tried to use the PLL, but I am unable to record audio.

    I tried setting Register 102 with different modes but could not achieve the desired effect:

    10100010: Can record waveform, but the waveform is not up to standard.
    10000010: Can record waveform, but the waveform is not up to standard.
    00100010: Unable to record audio.
    00000010: Unable to record audio.
    Additionally, I would like to know what a correctly recorded waveform looks like and how it differs from what I am currently getting.

    Best regards,

  • Hi,

    I found the proper clock settings. The major issue was the Q value. However for this to work you must change your format to DSP. Because the BCLK is so high (supports 16 channels of 32 bits), the codec cannot handle it correctly in I2S format (only 2 channels are expected). In DSP format it can work fine. I've attached a picture of what a proper signal should look like after using the settings below.

    w 30 01 80 #software reset
    w 30 07 00 #set fsref to 48k
    w 30 18 F8 #MIC1LP/M is differential, not connected to right ADC
    w 30 13 F8 #MIC1LP/M is differential
    w 30 13 C0 #MIC1LP/M is connected to left ADC
    w 30 13 80 #MIC1LP/M is 0dB
    w 30 13 84 #MIC1LP/M ADC is powered up
    w 30 09 40 #Audio Serial Format is DSP mode
    w 30 09 70 #Audio Serial Format is 32 bits
    w 30 03 22 #Q = 4
    w 30 65 01 #CODEC_CLKIN = CLKDIV_OUT
    w 30 66 A2 #CLKDIV and PLL use BCLK Input
    w 30 0F 00 #Unmute PGA

    Best regards,
    Jeff McPherson