2025-05-30 1:11 AM
Hello ST team,
I am working on USB audio class 2.0. I am using STM32F401, where I have connected SD card using SPI protocol and at the other end I have connected mobile using USB ( USB Audio Class 2.0). I have used tinyusb for USB support and FatFS for Filesystem.
AIM:
1) I have to read the PCM samples from SD card.
2) Concurrently I need to send PCM samples to over USB ( USB Audio Class 2.0) to HOST (mobile).
3) I am recording the PCM samples into my mobile phone recorder.
point 1 and 2 is achieved, but issue in occurring in point 3. The recorded file is noisy
I have using configuration which mention below:
tusb_desc_device_t const desc_device =
{
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200,
// Use Interface Association Descriptor (IAD) for Audio
// As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
.bDeviceClass = TUSB_CLASS_MISC,
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
.bDeviceProtocol = MISC_PROTOCOL_IAD,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
.bcdDevice = 0x0100,
.iManufacturer = 0x01,
.iProduct = 0x02,
.iSerialNumber = 0x03,
.bNumConfigurations = 0x01
};
The following is the following callback audiod_tx_done_cb(), i am filling the USB linear buffer using global buffer readbuff as mention in the below image line number 1061 and 1062.
where, FillTxBuff is defined as follows;
bool FillTxBuff(void)
{
static int counter = 0;
TCHAR* rres = f_gets((TCHAR*)readBuf, 192, &fil);
if(rres != 0)
{
counter++;
}
else if((rres == 0) && (counter != 0))
{
f_close(&fil);
counter = 0;
}
else
{
Error_Handler();
}
}
SPECULATION: Somehow we feel that, prior to data transfer, there might be issues in handshaking clock/frequency data.
Thanks
Sidharth Seela
2025-06-02 2:20 AM
Did you use the X-CUBE-AUDIO-KIT. If so, our expert @JonathanC may help you.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-06-02 2:31 AM - edited 2025-06-02 2:32 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution for best results; in particular, How to insert source code.
@sidharth_seela_at_amantya wrote:I have used tinyusb for USB support
You mean this: https://github.com/hathach/tinyusb ?
If so, that's not an ST project.
Have you followed their Getting Started advice:
Have you asked on their forum?
It says it's funded by Adafruit - so maybe also ask on the Adafruit forums?
2025-06-04 12:28 AM - last edited on 2025-06-04 12:50 AM by Andrew Neil
Hey FBL,
We need an example having headset functionality (both speaker and microphone recognized to the host), and running UAC1 class (lately have found that android has weak support for uac2). Pls help me find an example.
Thanks
Sidharth Seela