AnsweredAssumed Answered

STM32F7 BSP Record audio mono channel

Question asked by Hector Roussille on May 23, 2018
Latest reply on May 23, 2018 by Hector Roussille

Hello !

 

I am currently working on an audio application on STM32F7-discovery.

 

The example application is recording in stereo from the 2 MEMS microphones regardless of the parameters sent to :

 

BSP_AUDIO_IN_Init

 

I am now using my own application , but the behavior is the same , always stereo.

 

I suspected that it was because the codec initialization code in wm8994.c was turning on both channels when the input device specified is : INPUT_DEVICE_DIGITAL_MICROPHONE_2

 

So i changed the initialization of INPUT_DEVICE_DIGITAL_MICROPHONE_2 to only initialize the right channel and disable the left one In order to get a mono output from the wm8994.

 

  case INPUT_DEVICE_DIGITAL_MICROPHONE_2 :        /* Enable AIF1ADC2 (Left), Enable AIF1ADC2 (Right)       * Enable DMICDAT2 (Left), Enable DMICDAT2 (Right)       * Enable Left ADC, Enable Right ADC */
      //counter += CODEC_IO_Write(DeviceAddr, 0x04, 0x0C30);         counter += CODEC_IO_Write(DeviceAddr, 0x04, 0x0410);        /* Enable AIF1 DRC2 Signal Detect & DRC in AIF1ADC2 Left/Right Timeslot 1 */      //counter += CODEC_IO_Write(DeviceAddr, 0x450, 0x00DB);         counter += CODEC_IO_Write(DeviceAddr, 0x450, 0x00D9);        /* Disable IN1L, IN1R, IN2L, IN2R, Enable Thermal sensor & shutdown */      counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x6000);        /* Enable the DMIC2(Left) to AIF1 Timeslot 1 (Left) mixer path */      //counter += CODEC_IO_Write(DeviceAddr, 0x608, 0x0002);      counter += CODEC_IO_Write(DeviceAddr, 0x608, 0x0000);        /* Enable the DMIC2(Right) to AIF1 Timeslot 1 (Right) mixer path */      counter += CODEC_IO_Write(DeviceAddr, 0x609, 0x0002);        /* GPIO1 pin configuration GP1_DIR = output, GP1_FN = AIF1 DRC2 signal detect */      counter += CODEC_IO_Write(DeviceAddr, 0x700, 0x000E);        break;

 

 

 

I have indeed the left channel constantly at 0  so it is disabled , but the samples are still received.

 

I would like to receive only the RIGHT channel samples,  is this even possible ? I assumed that it is but maybe not..

 

I don't know if this is a DMA configuration error or another setting that i cannot find in the wm8994 datasheet.

 

If i understand correctly the two MEMS microphones share the same clock and data line the wm8994 is reading at both rising and falling edge on the data line , where each microphone alternately "send" it's PDM sample.

 

I looked for a way to read only on one edge on the wm8994 but without success so far.

 

My apologies if i missed something obvious, for now I only take the odd samples from the received buffer but i believe that a much cleaner solution is possible ?

 

Thanks in advance for any help !

Outcomes