pdm clock configuration (nrf5340)

Have used the sample code (Dmic) and generated the output.
the default configurations 
overlay:

&clock {
    hfclkaudio-frequency = <12288000>;
};

&pinctrl {
    pdm0_default_alt: pdm0_default_alt {
        group1 {
            psels = <NRF_PSEL(PDM_CLK, 1, 12)>,
                <NRF_PSEL(PDM_DIN, 1, 8)>;
        };
    };
};

dmic_dev: &pdm0 {
    status = "okay";
    pinctrl-0 = <&pdm0_default_alt>;
    pinctrl-names = "default";
    clock-source = "ACLK";
};

prj.conf:

CONFIG_AUDIO=y
CONFIG_AUDIO_DMIC=y

CONFIG_LOG=y
main.c :

#define MAX_SAMPLE_RATE  16000

    struct pcm_stream_cfg stream = {
        .pcm_width = SAMPLE_BIT_WIDTH,
        .mem_slab  = &mem_slab,
    };
    struct dmic_cfg cfg = {
        .io = {
            /* These fields can be used to limit the PDM clock
             * Configurations that the driver is allowed to use
             * To those supported by the microphone.
             */
            .min_pdm_clk_freq = 1000000,
            .max_pdm_clk_freq = 3500000,
            .min_pdm_clk_dc   = 40,
            .max_pdm_clk_dc   = 60,
        },
        .streams = &stream,
        .channel = {
            .req_num_streams = 1,
        },
    };

1) how to configure PCM with sampling frequency = 2KHz ?

have changed the MAX_SAMPLE_RATE to 2000

the output observed:
*** Booting Zephyr OS build 28a3fca7da5c ***
[00:00:00.543,640] <inf> dmic_sample: DMIC sample
[00:00:00.543,670] <inf> dmic_sample: PCM output rate: 2000, channels: 1
[00:00:00.543,701] <err> dmic_nrfx_pdm: Cannot find suitable PDM clock configuration.
[00:00:00.543,701] <err> dmic_sample: Failed to configure the driver: -22




is there any way to configure PCM with sampling frequency to 2khz? and how?

2) if PCM is 2KHz. what should be the PDM clock configuration?

Parents
  • hi, I have got logic
    there is relation between PDM and PCM.
    PDM= 64 * PCM

    #define MAX_SAMPLE_RATE  2000

      
        struct dmic_cfg cfg = {
            .io = {
                /* These fields can be used to limit the PDM clock
                 * configurations that the driver is allowed to use
                 * to those supported by the microphone.
                 */
                .min_pdm_clk_freq = 128000, //1000000,
                .max_pdm_clk_freq = 128000, //3500000,
                .min_pdm_clk_dc   = 40,
                .max_pdm_clk_dc   = 60,
       
            },
            .streams = &stream,
            .channel = {
                .req_num_streams = 1,
            },
        };
Reply
  • hi, I have got logic
    there is relation between PDM and PCM.
    PDM= 64 * PCM

    #define MAX_SAMPLE_RATE  2000

      
        struct dmic_cfg cfg = {
            .io = {
                /* These fields can be used to limit the PDM clock
                 * configurations that the driver is allowed to use
                 * to those supported by the microphone.
                 */
                .min_pdm_clk_freq = 128000, //1000000,
                .max_pdm_clk_freq = 128000, //3500000,
                .min_pdm_clk_dc   = 40,
                .max_pdm_clk_dc   = 60,
       
            },
            .streams = &stream,
            .channel = {
                .req_num_streams = 1,
            },
        };
Children
No Data
Related