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
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
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
// <o> PDM Microphone Power Control Pin
#define CONFIG_IO_PDM_MIC_PWR_CTRL 0x1A
/**@brief Audio buffer handler. */
typedef void (*drv_audio_buffer_handler_t)(int16_t *p_buffer, uint16_t samples);
static int16_t m_pdm_buff[2][CONFIG_PDM_BUFFER_SIZE_SAMPLES];
static drv_audio_buffer_handler_t m_buffer_handler;
static void m_audio_buffer_handler(int16_t *p_buffer, uint16_t samples)
{
// Audio processing
}
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(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);
if (buffer_handler == NULL)
{
return NRF_ERROR_INVALID_PARAM;
}
m_buffer_handler = buffer_handler;
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(m_audio_buffer_handler);
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
I am not able to move any further from this. Is there anything I can check with?
Hi,Vishnu .I am experiencing the same issue.How do you end up with the problem
Hi,Vishnu .I am experiencing the same issue.How do you end up with the problem