cancel
Showing results for 
Search instead for 
Did you mean: 

Send MEMS-Mic-Audio to PC-Host

TTimm
Associate II

Hi,

I try to connect a Nucleo-144-Board to Audacity.

The Project is based on CubeMx5.2/STM32Cube_FW_L4_V1.14.0.

I've read (successfully) in a Mems-Mic via SAI1/DMA2.

The USB-Audio-Device is shown in the Device-Manager and seems to be OK.

I've read the the UM1734 Rev.4

At the Moment I don't understand the Data-Direction of USB-Device (Middleware).

USBD_AUDIO_DataIn means Data-stream STM32L4->PC-USB-Host ??

USBD_AUDIO_DataOut means Data-stream PC-USB-Host->STM32L4 ??

Is DataIn() implemented at all?

I've found the "STM32CubeExpansion_MEMSMIC1_V4.0.0/Microphones_Streaming"-Example.

there is a file:

...\STM32CubeExpansion_MEMSMIC1_V4.0.0\Middlewares\ST\STM32_USB_Device_Library\Class\AUDIO\Src\usbd_audio_in.c with Function "USBD_AUDIO_Data_Transfer()"

Is this the Way to do the job?

Confused a little

Thomas

Vierling Production GmbH

2 REPLIES 2
Eleon BORLINI
ST Employee

Hi Thomas, can you try with this part of code concerning initialization in the main.c? You can find it in Smartmic package, and it should help you to initialize the USB audio communication (functions in usbd_audio_in.c file):

/* enable USB power on Pwrctrl CR2 register */
  HAL_PWREx_EnableVddUSB();   
  /*Init USB*/
  /* Initialize USB descriptor basing on channels number and sampling frequency */
  USBD_AUDIO_Init_Microphone_Descriptor(&hUSBDDevice, AUDIO_SAMPLING_FREQUENCY, AUDIO_CHANNELS);
  /* Init Device Library */
  temp = USBD_Init(&hUSBDDevice, &AUDIO_Desc, 0);
  /* Add Supported Class */
  temp = USBD_RegisterClass(&hUSBDDevice, &USBD_AUDIO);
  /* Add Interface callbacks for AUDIO Class */  
  temp = USBD_AUDIO_RegisterInterface(&hUSBDDevice, &USBD_AUDIO_fops);
  /* Start Device Process */
  temp = USBD_Start(&hUSBDDevice);  
  
  /* Start Microphone acquisition */
  temp = BSP_AUDIO_IN_Record(PCM_Buffer,0);

put this part of code just after these code lines

/* Configure Audio Input peripheral - DFSDM */  
  temp = BSP_AUDIO_IN_Init(AUDIO_SAMPLING_FREQUENCY, 16, AUDIO_CHANNELS);

Regards

TTimm
Associate II

Hi Eleon,

sorry, missleading advice...

BSP_AUDIO_IN_Init() -> BSP_AUDIO_IN_InitEx() (taken from the "STM32L496G-Discovery", nearly matching to my MCU)

Function !!! RECORD A FILE !!!

This function configures all the hardware required for the audio application (DFSDM or SAI, GPIOs, DMA and interrupt if needed).

The-Read-In of the MEMS-Mic works. (with DMA) as stated above.

I need a example for a USB-Device-(Input???)-Init like:

USBD_AUDIO_Init_Microphone_Descriptor(&hUsbDeviceFS, AUDIO_SAMPLING_FREQUENCY, AUDIO_CHANNELS); in "STM32CubeExpansion_MEMSMIC1"-Example.

or "USBD_AUDIO_CfgDesc[]"-Structure

That why my question: Is DataIn() implemented at all?

refer to UM1734 Rev.4

Kind regards

Thomas