This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PDM Sample Buffer

Hi,

I found your PDM Working Example. However I wonder what to make of the data I get.

What is the CONFIG_PDM_BUFFER_SIZE_SAMPLES for? Do I get 16Bit Bit-Schemes from which I must assemble my PCM Data or are there lets say 64 PCM Samples in the buffer.

Is there any Chance to configure the Decimation to different values?

Regards Daniel

Parents
  • Hi,

    The CONFIG_PDM_BUFFER_SIZE_SAMPLES is used to set the number of samples to allocate memory for in EasyDMA mode.

    The PDM bitstream is converted into 16-bit PCM samples by the digital filter, and is then filtered and down-sampled to reach the appropriate sample rate.

    You can configure the Decimation Filter Gain by adjusting the GAINL and GAINR registers.

    Snippet from the drv_audio_init() function in Thingy:52 SDK:

    ret_code_t drv_audio_init(drv_audio_buffer_handler_t buffer_handler)
    {
    nrf_drv_pdm_config_t pdm_cfg = NRF_DRV_PDM_DEFAULT_CONFIG(CONFIG_IO_PDM_CLK,
                                                              CONFIG_IO_PDM_DATA,
                                                              m_pdm_buff[0],
                                                              m_pdm_buff[1],
                                                              CONFIG_PDM_BUFFER_SIZE_SAMPLES);
    .
    .
    .
    pdm_cfg.gain_l      = CONFIG_PDM_GAIN;
    pdm_cfg.gain_r      = CONFIG_PDM_GAIN;
    
    .
    . 
    .
    
    
    return nrf_drv_pdm_init(&pdm_cfg, drv_audio_pdm_event_handler);
    }
    
Reply
  • Hi,

    The CONFIG_PDM_BUFFER_SIZE_SAMPLES is used to set the number of samples to allocate memory for in EasyDMA mode.

    The PDM bitstream is converted into 16-bit PCM samples by the digital filter, and is then filtered and down-sampled to reach the appropriate sample rate.

    You can configure the Decimation Filter Gain by adjusting the GAINL and GAINR registers.

    Snippet from the drv_audio_init() function in Thingy:52 SDK:

    ret_code_t drv_audio_init(drv_audio_buffer_handler_t buffer_handler)
    {
    nrf_drv_pdm_config_t pdm_cfg = NRF_DRV_PDM_DEFAULT_CONFIG(CONFIG_IO_PDM_CLK,
                                                              CONFIG_IO_PDM_DATA,
                                                              m_pdm_buff[0],
                                                              m_pdm_buff[1],
                                                              CONFIG_PDM_BUFFER_SIZE_SAMPLES);
    .
    .
    .
    pdm_cfg.gain_l      = CONFIG_PDM_GAIN;
    pdm_cfg.gain_r      = CONFIG_PDM_GAIN;
    
    .
    . 
    .
    
    
    return nrf_drv_pdm_init(&pdm_cfg, drv_audio_pdm_event_handler);
    }
    
Children
Related