Hi ,
I'm in Nrf52840Dongle Getting the PCM data in the following way, I want to print him to the serial port and then import it through Audacity to make sure I have the right data , but strangely enough, the data is noisy all the time. Can you give some advice how to do this?
I also want to confirm that nrfx_pdm_buffer_set this is a PCM buffer already or not .
static void process_audio_buffer(void)
{
z_impl_k_str_out(data_source_info.audio_source_info.audio_buffer, PDM_BUF_SIZE);
}
static void drv_audio_pdm_event_handler(nrfx_pdm_evt_t const * const p_evt)
{
uint8_t index = 0;
if (p_evt->error)
{
printk("pdm handler error %ld", p_evt->error);
return;
}
if(p_evt->buffer_released)
{
for (uint8_t l=0; l< PDM_BUF_NUM; l++)
{
if (pdm_buf[l].mic_buf == p_evt->buffer_released)
{
pdm_buf[l].released = true;
data_source_info.audio_source_info.audio_buffer = &pdm_buf[l].mic_buf;
process_audio_buffer();
break;
}
}
}
if(p_evt->buffer_requested)
{
for (uint8_t l=0; l<PDM_BUF_NUM; l++)
{
if (pdm_buf[l].released)
{
err_code = nrfx_pdm_buffer_set(pdm_buf[l].mic_buf, PDM_BUF_SIZE);
//APP_ERROR_CHECK(err_code);
pdm_buf[l].released = false;
index = l;
break;
}
}
}
}