Using onboard Digital Microphone with audio_i2s

Hi, I am currently outputting some audio (1000hz sine wave) via audio_i2s_blk_comp_cb_register and audio_i2s_set_next_buf (from audio_i2s.h) through the line out audio jack. My next step would be to capture sound from a microphone and play it back in real time. I noticed that the nrf5340 comes with a built-in microphone that can be initialized with the following:

LOG_INF("PDM turned on");
ret = cs47l63_comm_reg_conf_write(pdm_mic_enable_configure,
				  ARRAY_SIZE(pdm_mic_enable_configure));
if (ret) {
	return ret;
}

My question is how would I access the data from the built-in microphone? Is it through the rx_buf of audio_i2s_set_next_buf or something else entirely? Thanks!

  • You're on the right track.

    The VM3011 mic integrated on the Audio DK is connected to the CS47L63 at HW_CODEC_PDM1, not the nRF5340 directly. See the codec schematic in the Audio DK User Guide for connection details.

    Using the nrf5340_audio application as the basis, and assuming all the proper Kconfig options have been set, the PDM mic data should therefore be in the I2S RX buffer on each RXPTRUPD event, which will trigger whatever block_complete() callback you've registered.

    I haven't successfully accomplished this yet, but I'm looking forward to learning the knowledge that eventually gets shared in this thread, and studying your nrfadk-audio_i2s_sine1k repo as it further develops.

Related