cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 USB audio stream problem! AUDIO_AudioCmd_FS gets called only once.

Sami1
Associate II

Hello everyone

I am trying to implement a simple soundcard from using STM32F407G-DISC1 board.

It utilizes STM32F407. I am using CubeIDE version 1.10.1

I configured the USB to be Full-speed Device Only. And I configured the middleware as Audio class.

I set the the heap size at 0x4000, and stack size at 0x2000.

When I connect it via the USB, Windows surely recognizes it as "Speakers".

I know that when the microcontroller receives Audio data, I should have access to the samples in the "AUDIO_AudioCmd_FS" function.

The problem is that, when I send Audio data to the microcontroller, the AUDIO_AudioCmd_FS function gets called only once, and it does not get called again.

No matter how many times I resend Audio data from the PC to the microcontroller, the AUDIO_AudioCmd_FS function does not get called again.

Can anyone please help me with this issue?

1 ACCEPTED SOLUTION

Accepted Solutions
Sami1
Associate II

My problem is solved!

I want to point out 2 things:

  1. I was looking at the wrong function. "AUDIO_PeriodicTC_FS" is the function that I should use to get access to the audio samples
  2. I used the default Audio USB code that is generated by the CubeMX. This code turned out to be not stable. I got a more stable code from https://github.com/sdima1357/stm32f401cdu6_Audio

I copied the following files into my project:

/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c

/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c

/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c

/Middlewares/ST/STM32_USB_Device_Library/Class/AUDIO/Src/usbd_audio.c

/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c

/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c

/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c

/USB_DEVICE/App/usb_device.c

/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h

/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h

/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h

/Middlewares/ST/STM32_USB_Device_Library/Class/AUDIO/Inc/usbd_audio.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h

Now it works.. I think :)

View solution in original post

2 REPLIES 2
Sami1
Associate II

My problem is solved!

I want to point out 2 things:

  1. I was looking at the wrong function. "AUDIO_PeriodicTC_FS" is the function that I should use to get access to the audio samples
  2. I used the default Audio USB code that is generated by the CubeMX. This code turned out to be not stable. I got a more stable code from https://github.com/sdima1357/stm32f401cdu6_Audio

I copied the following files into my project:

/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c

/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c

/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c

/Middlewares/ST/STM32_USB_Device_Library/Class/AUDIO/Src/usbd_audio.c

/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c

/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c

/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c

/USB_DEVICE/App/usb_device.c

/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h

/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h

/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usb.h

/Middlewares/ST/STM32_USB_Device_Library/Class/AUDIO/Inc/usbd_audio.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h

/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h

Now it works.. I think :)

Hi @Sami​ 

Really glad to know you overcame this problem.

Please allow me to close this thread.

Thank you for your contribution and all the details you provided.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen