Hello, I'm trying to use two microphones in stereo mode of PDM (nrf52832, SDK17). Unfortunately, I have a major problem with my Right microphone. It seems that "nrfx_pdm_buffer_set" just put the Left one in the buffer.
This is my initialization for PDM in main function:
int main(void) { . . ... nrfx_pdm_config_t pdm_config = NRFX_PDM_DEFAULT_CONFIG(PDM_CLK_PIN, PDM_DATA_PIN); pdm_config.mode = PDM_MODE_OPERATION_Stereo; pdm_config.gain_l = PDM_GAIN; pdm_config.gain_r = PDM_GAIN; pdm_config.clock_freq = PDM_PDMCLKCTRL_FREQ_1000K; // 15625 Samples per Second pdm_config.edge = PDM_MODE_EDGE_LeftFalling; pdm_config.interrupt_priority = APP_IRQ_PRIORITY_HIGH; err_code = nrfx_pdm_init(&pdm_config, pdm_event_handler); APP_ERROR_CHECK(err_code); . . . }
This is "pdm_event_handler" function and "pdm_buffer" array:
int16_t pdm_buffer[PDM_BUFFER_SIZE_SAMPLES];
static void pdm_event_handler(nrfx_pdm_evt_t const *const p_evt) {
if (p_evt->buffer_requested) {
nrfx_pdm_buffer_set(pdm_buffer, PDM_BUFFER_SIZE_SAMPLES);
}
if (p_evt->buffer_released) {
do_something(pdm_buffer);
}
}
I tried many methods, including:
1. Make the type of "pdm_buffer" array uint32_t instead of int16_t.
2. Make "pdm_buffer" array 2 dimensional (int16_t pdm_buffer[2][PDM_BUFFER_SIZE_SAMPLES]).
3. Double the "PDM_BUFFER_SIZE_SAMPLES" constant in the buffer set ("nrfx_pdm_buffer_set(pdm_buffer, 2 * PDM_BUFFER_SIZE_SAMPLES)").
But non of them work.