AnsweredAssumed Answered

USB Iso IN EP issue - Device sends only 4 bytes OR PC reads only 4 bytes

Question asked by Pradeep Gowda on May 31, 2017

Hi,

I am trying to make STM32F407 discovery board work in both IN and OUT directions. I am able to configure the descriptors and get my device recognized on Windows 7 PC as both playback and recording device with support for 2 channels, 16 bits wide PCM data in each direction.

Playback is working just fine. However, the issue is with IN direction data.

I am trying to loop back my the ISO OUT EP data back on to ISO IN EP data to verify the integrity of data first. as soon as I start the playback, I get Control Pipe read requests for 4 bytes each and every transaction reads 10 such packets. The IN transaction shows only 4 valid bytes and rest are 0's. Any idea what could be going wrong.

 

Eagerly looking for some help. Thanks in advance!!!

 

Here is a snapshot of the packet from Device Monitor Studio:

131588: Isochronous Transfer (UP), 2017-05-30 19:32:12.2540194 +0.0007559. (1. Device: Headset Interface) Status: 0x00000000
Pipe Handle: Control PipeGet from the device
Start Frame: 27022, Number of packets: 10, Error Count: 0, Start Transfer ASAP

Transfer Packet 0: Offset: 0x0, Length: 0x4, Status: 0x0
Transfer Packet 1: Offset: 0x180, Length: 0x4, Status: 0x0
Transfer Packet 2: Offset: 0x300, Length: 0x4, Status: 0x0
Transfer Packet 3: Offset: 0x480, Length: 0x4, Status: 0x0
Transfer Packet 4: Offset: 0x600, Length: 0x4, Status: 0x0
Transfer Packet 5: Offset: 0x780, Length: 0x4, Status: 0x0
Transfer Packet 6: Offset: 0x900, Length: 0x4, Status: 0x0
Transfer Packet 7: Offset: 0xa80, Length: 0x4, Status: 0x0
Transfer Packet 8: Offset: 0xc00, Length: 0x4, Status: 0x0
Transfer Packet 9: Offset: 0xd80, Length: 0x4, Status: 0x0

 

77 08 FD 0B 00 00 00 00 00 00 00 00 00 00 00 00 w.ý.............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 ........

 

The descriptors are:

 

__ALIGN_BEGIN uint8_t USBD_Class_CfgDesc[USB_CONFIG_DESC_TOTAL_SIZE] __ALIGN_END =
{
/* Configuration Descriptor */
USB_LEN_CFG_DESC, /*bLength - 9 */
USB_DESC_TYPE_CONFIGURATION, /*bDescriptorType - 2 */
LOBYTE(USB_CONFIG_DESC_TOTAL_SIZE), /*wTotalLength */
HIBYTE(USB_CONFIG_DESC_TOTAL_SIZE),
USB_TOTAL_INTERFACES, /*bNumInterfaces */
0x01, /*bConfigurationValue */
USBD_IDX_CONFIG_STR, /*iConfiguration */
0xC0, /*bmAttributes BUS Powered*/
USB_MAX_POWER, /*bMaxPower = 100 mA */

 

/*Interface Descriptor 0 - Alt 0 (Audio Control)*/
USB_LEN_IF_DESC, /*bLength */
USB_DESC_TYPE_INTERFACE, /*bDescriptorType */
0x00, /*bInterfaceNumber */
0x00, /*bAlternateSetting */
0x00, /*bNumEndpoints */
USB_DEVICE_CLASS_AUDIO, /*bInterfaceClass */
AUDIO_SUBCLASS_AUDIOCONTROL, /*bInterfaceSubClass */
AUDIO_PROTOCOL_UNDEFINED, /*bInterfaceProtocol */
USBD_IDX_INTERFACE_STR, /*iInterface */

 

/* Audio control interface header descriptor */
0x0A, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_CONTROL_HEADER, /*bDescriptorSubtype */
0x00, /*bcdADC */
0x01,
0x4E, /*wTotalLength - 78 */
0x00,
0x02, /*bInCollection */
0x01, /*baInterfaceNr 1 */
0x02, /*baInterfaceNr 2 */

 

/*Audio Control Input Terminal Descriptor */
AUDIO_INPUT_TERMINAL_DESC_SIZE, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_CONTROL_INPUT_TERMINAL, /*bDescriptorSubtype */
0x01, /*bTerminalID */
0x01, /*wTerminalType */
0x01, /*AUDIO_TERMINAL_USB_STREAMING 0x0101 */
0x00, /*bAssocTerminal */
0x02, /*bNrChannels */
0x03, /*wChannelConfig */
0x00, /*0x0003 Stereo-LF and RF */
0x00, /*iChannelNames */
0x00, /*iTerminal */

 

/*Audio Control Feature Unit Descriptor*/
0x0D, /*bLength*/
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_CONTROL_FEATURE_UNIT, /*bDescriptorSubtype */
AUDIO_OUT_FEATURE_ID, /*bUnitID */
0x01, /*bSourceID */
0x02, /*bControlSize 1 byte/ch */
0x01, /*bmaControls(0) Master */
0x00, /*bmaControls(0) Master */
0x00, /*bmaControls(1) Channel 0*/
0x00, /*bmaControls(1) Channel 0*/
0x00, /*bmaControls(2) Channel 1*/
0x00, /*bmaControls(2) Channel 1*/
0x00, /*iTerminal */

 

/*Audio Control Output Terminal Descriptor*/
AUDIO_OUTPUT_TERMINAL_DESC_SIZE, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_CONTROL_OUTPUT_TERMINAL, /*bDescriptorSubtype */
0x03, /*bTerminalID */
0x02, /*wTerminalType 0x0302 */
0x03,
0x00, /*bAssocTerminal */
AUDIO_OUT_FEATURE_ID, /*bSourceID */
0x00, /*iTerminal */

 

/*Audio Control Input Terminal Descriptor*/
AUDIO_INPUT_TERMINAL_DESC_SIZE, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_CONTROL_INPUT_TERMINAL, /*bDescriptorSubtype */
0x04, /*bTerminalID */
0x01, /*wTerminalType Microphone*/
0x02,
0x00, /*bAssocTerminal */
AUDIO_IN_CHANNEL_COUNT, /*bNrChannels */
0x03, /*wChannelConfig */
0x00,
0x00, /*iChannelNames */
0x00, /*iTerminal */

 

/*Audio Control Feature Unit Descriptor*/
0x0D, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_CONTROL_FEATURE_UNIT, /*bDescriptorSubtype */
AUDIO_IN_FEATURE_ID, /*bUnitID */
0x04, /*bSourceID */
0x02, /*bControlSize 2 byte/ch */
0x01, /*bmaControls(0) Master */
0x00, /*bmaControls(0) Master */
0x00, /*bmaControls(1) Channel 0*/
0x00, /*bmaControls(1) Channel 0*/
0x00, /*bmaControls(1) Channel 0*/
0x00, /*bmaControls(1) Channel 0*/
0x00, /*iTerminal */

 

/*Audio Control Output Terminal Descriptor*/
AUDIO_OUTPUT_TERMINAL_DESC_SIZE, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_CONTROL_OUTPUT_TERMINAL, /*bDescriptorSubtype */
0x06, /*bTerminalID */
0x01, /*wTerminalType interface to iso EP*/
0x01,
0x04, /*bAssocTerminal */
AUDIO_IN_FEATURE_ID, /*bSourceID */
0x00, /*iTerminal */

 

/*Interface Descriptor 1 - Alt 0 (Audio Streaming)*/
USB_LEN_IF_DESC, /*bLength */
USB_DESC_TYPE_INTERFACE, /*bDescriptorType */
AUDIO_STREAMING_INTERFACE_ID1, /*bInterfaceNumber */
0x00, /*bAlternateSetting */
0x00, /*bNumEndpoints */
USB_DEVICE_CLASS_AUDIO, /*bInterfaceClass - Audio */
AUDIO_SUBCLASS_AUDIOSTREAMING, /*bInterfaceSubClass - Audio Streaming*/
AUDIO_PROTOCOL_UNDEFINED, /*bInterfaceProtocol - Undefined*/
0x00, /*iInterface */

 

/*Interface Descriptor 1 - Alt 1 (Audio Streaming)*/
USB_LEN_IF_DESC, /*bLength */
USB_DESC_TYPE_INTERFACE, /*bDescriptorType */
AUDIO_STREAMING_INTERFACE_ID1, /*bInterfaceNumber */
0x01, /*bAlternateSetting */
0x01, /*bNumEndpoints */
USB_DEVICE_CLASS_AUDIO, /*bInterfaceClass - Audio */
AUDIO_SUBCLASS_AUDIOSTREAMING, /*bInterfaceSubClass - Streaming*/
AUDIO_PROTOCOL_UNDEFINED, /*bInterfaceProtocol - Undefined*/
0x00, /*iInterface*/

 

/*Audio Streaming Interface Descriptor*/
AUDIO_STREAMING_INTERFACE_DESC_SIZE,/*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_STREAMING_GENERAL, /*bDescriptorSubtype */
0x01, /*bTerminalLink */
0x01, /*bDelay */
0x01, /*wFormatTag AUDIO_FORMAT_PCM 0x0001*/
0x00,

 

/*Audio Streaming Format Type Descriptor*/
0x1D, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_STREAMING_FORMAT_TYPE, /*bDescriptorSubtype */
AUDIO_FORMAT_TYPE_III, /*bFormatType */
0x02, /*bNrChannels */
0x02, /*bSubFrameSize : 2 Bytes per frame (16bits)*/
0x10, /*bBitResolution (16-bits per sample)*/
0x07, /*bSamFreqType 7 frequencies supported*/
AUDIO_SAMPLE_FREQ(8000), /* 3 bytes per freq */
AUDIO_SAMPLE_FREQ(16000),
AUDIO_SAMPLE_FREQ(24000),
AUDIO_SAMPLE_FREQ(32000),
AUDIO_SAMPLE_FREQ(44100),
AUDIO_SAMPLE_FREQ(48000),
AUDIO_SAMPLE_FREQ(96000),

 

/*Audio Streaming Isochronous Audio Data Endpoint Descriptor */
AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /*bLength */
USB_DESC_TYPE_ENDPOINT, /*bDescriptorType */
AUDIO_OUT_EP, /*bEndpointAddress 1 out */
USBD_EP_TYPE_ISOC, /*bmAttributes */
AUDIO_PACKET_SZE(MAX_USBD_AUDIO_FREQ, AUDIO_OUT_CHANNEL_COUNT, 2), /*wMaxPacketSize in Bytes (Freq(Samples)*2(Stereo)*2(HalfWord))*/
0x01, /*bInterval */
0x00, /*bRefresh */
0x00, /*bSynchAddress */

/*Endpoint Descriptor*/
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /*bLength */
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_ENDPOINT_GENERAL, /*bDescriptor */
0x01, /*bmAttributes 0x01 sampling frequency control */
0x00, /*bLockDelayUnits */
0x00, /*wLockDelay */
0x00,

 

/*Interface Descriptor 2 - Alt 0 (Audio Streaming)*/
USB_LEN_IF_DESC, /*bLength */
USB_DESC_TYPE_INTERFACE, /*bDescriptorType */
AUDIO_STREAMING_INTERFACE_ID2, /*bInterfaceNumber */
0x00, /*bAlternateSetting */
0x00, /*bNumEndpoints */
USB_DEVICE_CLASS_AUDIO, /*bInterfaceClass - Audio */
AUDIO_SUBCLASS_AUDIOSTREAMING, /*bInterfaceSubClass - Audio Streaming*/
AUDIO_PROTOCOL_UNDEFINED, /*bInterfaceProtocol - Undefined*/
0x01, /*iInterface */

 

/*Interface Descriptor 2 - Alt 1 (Audio Streaming)*/
USB_LEN_IF_DESC, /*bLength */
USB_DESC_TYPE_INTERFACE, /*bDescriptorType */
0x02, /*bInterfaceNumber */
0x01, /*bAlternateSetting */
0x01, /*bNumEndpoints */
USB_DEVICE_CLASS_AUDIO, /*bInterfaceClass - Audio */
AUDIO_SUBCLASS_AUDIOSTREAMING, /*bInterfaceSubClass - Audio Streaming*/
AUDIO_PROTOCOL_UNDEFINED, /*bInterfaceProtocol - Undefined*/
0x01, /*iInterface */

 

/*Audio Streaming Interface Descriptor*/
AUDIO_STREAMING_INTERFACE_DESC_SIZE,/*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_STREAMING_GENERAL, /*bDescriptorSubtype */
0x06, /*bTerminalLink (Output terminal of second stream)*/
0x01, /*bDelay */
0x01, /*wFormatTag AUDIO_FORMAT_PCM 0x0001*/
0x00,

 

/*Audio Streaming Format Type Descriptor*/
0x1D, /*bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_STREAMING_FORMAT_TYPE, /*bDescriptorSubtype */
AUDIO_FORMAT_TYPE_III, /*bFormatType */
0x02, /*bNrChannels */
0x02, /*bSubFrameSize : 2 Bytes per frame (16bits)*/
0x10, /*bBitResolution (16-bits per sample) */
0x07, /*bSamFreqType 7 frequencies supported */
AUDIO_SAMPLE_FREQ(8000), /*3 bytes per freq */
AUDIO_SAMPLE_FREQ(16000),
AUDIO_SAMPLE_FREQ(24000),
AUDIO_SAMPLE_FREQ(32000),
AUDIO_SAMPLE_FREQ(44100),
AUDIO_SAMPLE_FREQ(48000),
AUDIO_SAMPLE_FREQ(96000),

 

/*Audio Streaming Isochronous Audio Data Endpoint Descriptor*/
AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /*bLength */
USB_DESC_TYPE_ENDPOINT, /*bDescriptorType */
AUDIO_IN_EP, /*bEndpointAddress 1 in endpoint*/
0x01, /*bmAttributes */
AUDIO_PACKET_SZE(MAX_USBD_AUDIO_FREQ, AUDIO_IN_CHANNEL_COUNT, 2), /*wMaxPacketSize in Bytes (Freq(Samples)*2(Stereo)*2(HalfWord))*/
0x01, /*bInterval */
0x00, /*bRefresh */
0x00, /*bSynchAddress */

 

/*Endpoint Descriptor*/
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /*bLength */
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType */
AUDIO_ENDPOINT_GENERAL, /*bDescriptor */
0x01, /*bmAttributes */
0x00, /*bLockDelayUnits */
0x00, /*wLockDelay */
0x00,

};

Outcomes