2

PDM working example

viznu3391 gravatar image

asked 2017-05-19 14:37:40 +0200

hi, Is there any working PDM example for nRF52832? or can anyone give a sample initialization code for PDM with easyDMA using the inbuilt nrf_pdm_drv functions?

Regardss, Vishnu

edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
1
sigurdon gravatar image

answered 2017-05-22 15:54:47 +0200

Hi,

We don't have any full examples yet. But here is some code to get you started:

#include "nrf_drv_pdm.h"

#define CONFIG_PDM_BUFFER_SIZE_SAMPLES 320

// <o> PDM Decimation Filter Gain <0x00-0x50>
// <i> For details on the PDM decimation filter, 
//see the 'Decimation filter' section in the nRF52 Product Specification document.
#define CONFIG_PDM_GAIN 0x28


// <o> PDM CLK Pin
#define CONFIG_IO_PDM_CLK 0x06

// <o> PDM DATA Pin
#define CONFIG_IO_PDM_DATA 0x05

static int16_t                      m_pdm_buff[2][CONFIG_PDM_BUFFER_SIZE_SAMPLES];


static void drv_audio_pdm_event_handler(uint32_t *p_buffer, uint16_t length)
{
    //m_buffer_handler((int16_t *)p_buffer, length);
}

uint32_t drv_audio_init(void)
{
    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);
}






/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;

    err_code = drv_audio_init();
    APP_ERROR_CHECK(err_code);

    err_code =  nrf_drv_pdm_start();
    APP_ERROR_CHECK(err_code);
    while (true)
    {
        // Do nothing.
    }
}
/** @} */

I also recommend taking a look at the PDM driver. It's located in SDK_folder\components\drivers_nrf\pdm

edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

User menu

    or sign up

Recent questions

Question Tools

1 follower

Stats

Asked: 2017-05-19 14:37:40 +0200

Seen: 71 times

Last updated: May 22