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