cancel
Showing results for 
Search instead for 
Did you mean: 

AUDIO_AudioCmd_FS gets called only once

Sami1
Associate II

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

1 REPLY 1
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 :)