Post Go back to editing

Issue with ADAU7118 - Recording Duration Mismatch on Verdin AM62D Board with Single Microphone

Category: Hardware
Product Number: ADAU7118

Hello,

I am working with an ADAU7118 PDM-to-I2S converter on a Verdin AM62D board. I have connected a single IM72D128V01 microphone to the ADAU7118 on channel 0, with clock-0.

Here are the relevant changes made in the device tree:

&main_i2c3 {
    status = "okay";
    #sound-dai-cells = <0>;
    #address-cells = <1>;
    status = "okay";
    adau7118_codec: adau7118-codec@17 {
        compatible = "adi,adau7118";
        #sound-dai-cells = <0>;
        reg = <0x17>;
        status = "okay";
        adi,pdm-clk-map = <0 0 0 0>;
        adi,decimation-ratio = <16>;
    };

    sound {
        compatible = "simple-audio-card";
        simple-audio-card,bitclock-slave = <&codec_dai>;
        simple-audio-card,format = "i2s";
        simple-audio-card,frame-slave = <&codec_dai>;
        simple-audio-card,mclk-fs = <256>;
        simple-audio-card,name = "adau7118";
        simple-audio-card,widgets = "Microphone", "Microphone Jack";
        simple-audio-card,routing = "PDM_DAT0", "Microphone Jack";

        codec_dai: simple-audio-card,codec {
            sound-dai = <&adau7118_codec>;
        };

        simple-audio-card,cpu {
            dai-tdm-slot-num = <2>; // Number of TDM slots
            dai-tdm-slot-width = <32>; // Width of each TDM slot
            sound-dai = <&mcasp0>;
        }

I am using the following command to capture audio:

arecord -D hw:0,0 -V mono -c 1 -f S16_LE -r 8000 -v -t wav mic.wav

For a 10-second recording, I am getting a .wav file with around 50-60 seconds of audio when I play it back.

Could you please suggest:

How to properly configure the ADAU7118 for recording from a single microphone.
Any changes needed in the device tree.
If there is something wrong with the decimation ratio or PDM clock settings that might cause this issue.
Thank you for your help!

  • Hi,

    Can you please tell us who you have the ALSA mixer configured?

    you can interrogate with "amixer" command and please paste here the response for the ADAU7118 card.

    Also, can you please check for example that if you supply a 1kHz tone to the microphone you get a 1kHz sine when you play back the recording?

    If the frequency is altered you have an data interpretation problem or the SAI is not sampling at 8kHz, 16 bit as you're requesting through arecord command.

    I see you set the SAI in TDM mode with 32 bit per sample but in ALSA you request 16 bit. Is there any reason for this?

    Can you also tell us please which is the DMIC CLK you're trying to achieve? According to datasheet IM72D128V01 support 768kHz, 1.536MHz, 2.4MHz, 3.072MHz and 4.8MHz but you have to set a target because based on Fclock the SNR value varies.

    BR,

    Bogdan

  • Hi  ,
    Sorry for the late reply.

    For the above configuration of device tree is working fine with below command:
    arecord -D hw:0,0 -V mono -c 1 -f S16_LE -r 32000 -t wav mic_hb11.wav
    I have given sample rate as 32Khz , now proper audio for particular duartion i can able to arecord.
    And i have added 8192000Hz I2S clock like below.

            mcasp0: audio-controller@2b00000 {
                    compatible = "ti,am33xx-mcasp-audio";
                    reg = <0x00 0x02b00000 0x00 0x2000>,
                          <0x00 0x02b08000 0x00 0x400>;
                    reg-names = "mpu", "dat";
                    interrupts = <GIC_SPI 236 IRQ_TYPE_LEVEL_HIGH>,
                                 <GIC_SPI 235 IRQ_TYPE_LEVEL_HIGH>;
                    interrupt-names = "tx", "rx";
    
                    dmas = <&main_bcdma 0 0xc500 0>, <&main_bcdma 0 0x4500 0>;
                    dma-names = "tx", "rx";
    
                    clocks = <&k3_clks 190 0>;
                    clock-names = "fck";
                    assigned-clocks = <&k3_clks 190 0>;
                    assigned-clock-parents = <&k3_clks 190 2>;
                    assigned-clock-rates = <8192000>;
                    power-domains = <&k3_pds 190 TI_SCI_PD_EXCLUSIVE>;
                    status = "disabled";

    &main_i2c3 {
            status = "okay";
            #sound-dai-cells = <0>;
            #address-cells = <1>;
            status = "okay";
            adau7118_codec: adau7118-codec@17 {
                    compatible = "adi,adau7118";
                    #sound-dai-cells = <0>;
                    reg = <0x17>;
                    status = "okay";
                    adi,pdm-clk-map = <1 0 0 0>;
                    adi,decimation-ratio = <16>;
             };
    
    };
    


    Now i am getting amixer output like below:
    amixer
    Simple mixer control 'PDM0',0
      Capabilities: cswitch cswitch-joined
      Capture channels: Mono
      Mono: Capture [on]
    Simple mixer control 'PDM1',0
      Capabilities: cswitch cswitch-joined
      Capture channels: Mono
      Mono: Capture [on]
    Simple mixer control 'PDM2',0
      Capabilities: cswitch cswitch-joined
      Capture channels: Mono
      Mono: Capture [on]
    Simple mixer control 'PDM3',0
      Capabilities: cswitch cswitch-joined
      Capture channels: Mono
      Mono: Capture [on]
    


    Now i have to connect 3 mics to the adau7118, for that what are the changes need to be modify in the device tree.

    Does below configuartion work for 3 mics connected together,
    &main_i2c3 {
        status = "okay";
        #address-cells = <1>;
        #size-cells = <0>;
    
        adau7118_codec: adau7118-codec@17 {
            compatible = "adi,adau7118";
            reg = <0x17>;
            adi,pdm-clk-map = <1 1 1 0>;  // Enable the PDM clocks
            adi,decimation-ratio = <16>;  // Decimation ratio
            status = "okay";
        };
    
        sound {
            compatible = "simple-audio-card";
            simple-audio-card,bitclock-slave = <&codec_dai>;
            simple-audio-card,frame-slave = <&codec_dai>;
            simple-audio-card,format = "i2s";
            simple-audio-card,mclk-fs = <256>;
            simple-audio-card,name = "adau7118";
            simple-audio-card,widgets =
                "Microphone", "Mic1",
                "Microphone", "Mic2",
                "Microphone", "Mic3";
            simple-audio-card,routing =
                "PDM_DAT0", "Mic1",
                "PDM_DAT1", "Mic2",
                "PDM_DAT2", "Mic3";
    
            codec_dai: simple-audio-card,codec {
                sound-dai = <&adau7118_codec>;
            };
    
            simple-audio-card,cpu {
                sound-dai = <&mcasp0>;
                dai-tdm-slot-num = <6>;  // Number of slots (6 channels)
                dai-tdm-slot-width = <32>; // Slot width (32 bits for each channel)
            };
        };
    };
    

  • Hi  ,
    I have made above configuration as it as and changed dai-tdm-slot-num=<8>;
    I am getting mic-3 data on channel-4 i am suppose to get on channel-5 using the below command

    arecord -D hw:0,0 -V mono -c 4 -f S16_LE -r 32000 test.wav


    but when i tried to below command getting MAX range:
    arecord -D hw:0,0 -V mono -c 5 -f S16_LE -r 32000 test.wav
    Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 32000 Hz, Channels 5
    ##################################################+| MAX


    And i observed that, when i set register 0x41 on address 0x07 for tdm mode, as soon as i executed arecord command, register is changing to 0x40 means stereo mode.

    I need solution on this.

  • Please check the audio interface format.

    According to codecs/adau7118.c#L161 in order to have TDM mode you have to use left justified so please set      
    simple-audio-card,format = "left_j";

  • Hi  ,
    Thank you for your response,

    I have just set simple-audio-card,format = "left_j";
    still arecord channel -5 is saying max only and 0x07 register is stereo only now value changed to 0x42.

    Is above device tree ok for all channels.?
    bacause I am getting mic-3 data on channel-4 i am suppose to get on channel-5 using alsa command.
    Now we have connected only 3 mics PDM_DATA0 for MIC-1 PDM_DATA1 for mIC-2, PDM_DATA3 for MIC-3.
    PDM_CLK0 for first 2 mics and PDM_CLK1 for 3rd mic.

    Thanks & Regards
    Teju S H

  • I think the slot number is not correctly configured.

    Can you please enable the dynamic debug messages in kernel and check in DMESG for the following message?


    codecs/adau7118.c#L235

    And please revert to "simple-audio-card,format = "i2s";". Sorry, I looked at the wrong bit field for register 0x07. It looks like the stereo/TDM mode is controlled only by the slots number.

  • Hi  ,
    CONFIG_DYNAMIC_DEBUG this configuration is enabled, but still i didnt get the prints from dmesg 
    dmesg | grep "Set tdm"
    before arecord command below are the i2c-dump register status:

           0  1   2   3   4   5  6   7   8   9   a   b   c   d   e   f
    00: 41 71 18 01 0f c0 d0 40 00 00 10 20 30 40 50 60
    10: 70 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00

    while capturing audio using arecord -D hw:0,0 -V mono -c 5 -f S16_LE -r 52000 test_67.wav i2c-dump register status:

           0   1   2   3   4   5   6   7   8   9  a   b   c   d   e   f
    00: 41 71 18 01 3f c0 d0 40 00 01 11 21 31 41 51 61
    10: 71 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.