I2S Microphone Example

Brief

This example shows how to use the i2s microphone model on gvsoc without gvcontrol. To do this, a custom board is created based on gap9evk with the audio addod pdm. Two i2s microphones are connected to SAI0 to produce sound for the 2 channels. In the mic intension, you can decide whether you want to use a sinusoid generated internally by the my, or whether you want to use a wav file. Then simply specify the I2S slot width and frequency. The microphone will use an internal interpolator if the file frequency and the I2S interface frequency don’t match. It will also adapt to the slot width.

To connect the microphone, simply retrieve the slot intensity from the card. Instantiate the microphone as needed for the left and right channels and connect it to the i2s interface.

gap = self.get_component('chip')
# ...
i2s_mic_l = Microphone_i2s(self, 'i2s_mic_l', channel = "left", frequency = 16000, width = 32, generated_freq = 200)
i2s_mic_l.get_itf('i2s').bind(gap.get_itf_i2s(0))
i2s_mic_r = Microphone_i2s(self, 'i2s_mic_r', channel = "right", frequency = 16000, width = 32, input_file =script_dir +  "/sweep_24bit_48k.wav")
i2s_mic_r.get_itf('i2s').bind(gap.get_itf_i2s(0))

Please note that if you inherit the Gap9evk_pdm_addon board, 2 dacs and microphones are already connected to interfaces 1 and 2.

GAP Code

The code running on the GAP initializes the I2S interfaces, configures the DAC, and performs a simple PCM in -> PDM out.