Azure RTOS USBX. Changing USB Audio interrupt period from 1ms to 4ms.

Serhii Cherkasov 81 Reputation points
2023-08-09T19:07:54.33+00:00

Hello, I need to change bInterval from 1ms to 4ms, I believe it will lower pressure on the system. If USB interrupts will occur not every 1ms, but 4ms.

https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/usbspec/ns-usbspec-_usb_endpoint_descriptor - I read here I need to change bInterval from 4 to 32. And Transfer type from isochronous to interrupt. I think I changed that and tested with this https://www.thesycon.de/eng/usb_descriptordumper.shtml

I tried these settings:

bmAttributes 0b0011
wMaxPacketSize 482ch2bytes*4ms= 768 bytes
bInterval 0x6 = 2^(6-1) microframes = 32 * 125us = 4000us

	/* ------------------------- Endpoint Descriptor */
	/* [242] 0 bLength, bDescriptorType */ 7, 0x05,
	/* [244] 2 bEndpointAddress */ 0x83,
	/* [245] 3 bmAttributes : 0x0D (Sync|ISO) */ 0x03,
	/* [246] 4 wMaxPacketSize : 0xC0 (48kHz * 2 channels * 2 bytes width) */ 0x00, 0x03,
	/* [248] 6 bInterval : 0x04 (1ms) */ 0x6,

The whole descriptor is below:

	/* -------------------------- Device Descriptor  */
	/* [0 ] 0  bLength, bDescriptorType */ 0x12, 0x01,
	/* [2 ] 2  bcdUSB : 0x200 (2.00) */ 0x00, 0x02,
	/* [4 ] 4  bDeviceClass : 0x00 (see interface) */ 0xEF,
	/* [5 ] 5  bDeviceSubClass : 0x00 (see interface) */ 0x02,
	/* [6 ] 6  bDeviceProtocol : 0x00 (see interface) */ 0x01,
	/* [7 ] 7  bMaxPacketSize0 */ 64,
	/* [8 ] 8  idVendor, idProduct */ 0x84, 0x84, 0x03, 0x00,
	/* [12] 12 bcdDevice */ 0x00, 0x02,
	/* [14] 14 iManufacturer, iProduct, iSerialNumber */ 1, 2, 3,
	/* [17] 17 bNumConfigurations */ 1,
	/* ---------------- Device Qualifier Descriptor */
	/* [18] 0 bLength, bDescriptorType */ 0x0A, 0x06,
	/* [20] 2 bcdUSB : 0x200 (2.00) */ 0x00,0x02,
	/* [22] 4 bDeviceClass : 0x00 (see interface) */ 0xEF,
	/* [23] 5 bDeviceSubClass : 0x00 (see interface) */ 0x02,
	/* [24] 6 bDeviceProtocol : 0x00 (see interface) */ 0x01,
	/* [25] 7 bMaxPacketSize0 */ 64,
	/* [26] 8 bNumConfigurations */ 1,
	/* [27] 9 bReserved */ 0,
	/* --- Configuration Descriptor (9+8+73+55=145, 0x91) */
	/* [28] 0 bLength, bDescriptorType */ 9, 0x02,
	/* [30] 2 wTotalLength */ 229, 0x00,
	/* [32] 4 bNumInterfaces, bConfigurationValue */ 3, 1,
	/* [34] 6 iConfiguration */ 0,
	/* [35] 7 bmAttributes, bMaxPower */ 192, 50,
	/* ----------- Interface Association Descriptor */
	/* [37] 0 bLength, bDescriptorType */ 8, 0x0B,
	/* [39] 2 bFirstInterface, bInterfaceCount */ 0, 3,
	/* [41] 4 bFunctionClass : 0x01 (Audio) */ 0x01,
	/* [42] 5 bFunctionSubClass : 0x00 (UNDEFINED) */ 0x00,
	/* [43] 6 bFunctionProtocol : 0x20 (VERSION_02_00) */ 0x20,
	/* [44] 7 iFunction */ 0,
	/* --- Interface Descriptor #0: Control (9+64=73) */
	/* [45] 0 bLength, bDescriptorType */ 9, 0x04,
	/* [47] 2 bInterfaceNumber, bAlternateSetting */ 0, 0,
	/* [49] 4 bNumEndpoints */ 0,
	/* [50] 5 bInterfaceClass : 0x01 (Audio) */ 0x01,
	/* [51] 6 bInterfaceSubClass : 0x01 (AudioControl) */ 0x01,
	/* [52] 7 bInterfaceProtocol : 0x20 (VERSION_02_00) */ 0x20,
	/* [53] 8 iInterface */ 0,
	/* --- Audio 2.0 AC Interface Header Descriptor (9+8+17+18+12=64, 0x40) */
	/* [54] 0 bLength */ 9,
	/* [55] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x01,
	/* [57] 3 bcdADC */ 0x00, 0x02,
	/* [59] 5 bCategory : 0x04 (Headset) */ 0x08,
	/* [60] 6 wTotalLength */ 93, 0,
	/* [62] 8 bmControls */ 0x00,
	/* -------- Audio 2.0 AC Clock Source Descriptor */
	/* [63] 0 bLength */ 8,
	/* [64] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x0A,
	/* [66] 3 bClockID */ 24,
	/* [67] 4 bmAttributes : 0x05 (Sync|InternalFixedClk) */ 0x01,
	/* [68] 5 bmControls : 0x01 (FreqReadOnly) */ 0x01,
	/* [69] 6 bAssocTerminal, iClockSource */ 0x00, 0,
	/* ------ Audio 2.0 AC Input Terminal Descriptor */
	/* [71] 0 bLength */ 17,
	/* [72] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x02,
	/* [74] 3 bTerminalID */ 0x12,
	/* [75] 4 wTerminalType : 0x0101 (USB Streaming) */ 0x01, 0x01,
	/* [77] 6 bAssocTerminal, bCSourceID */ 0x00, 0x18,
	/* [79] 8 bNrChannels */ 2,
	/* [80] 9 bmChannelConfig */ 0x03, 0x00, 0x00, 0x00,
	/* [84] 13 iChannelNames, bmControls, iTerminal */ 0, 0x00, 0x00, 0,
	/* -------- Audio 2.0 AC Feature Unit Descriptor */
	/* [88] 0 bLength */ 18,
	/* [89] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x06,
	/* [91] 3 bUnitID, bSourceID */ 0x16, 0x12,
	/* [93] 5 bmaControls(0) : 0x0F (VolumeRW|MuteRW) */ 0x0F, 0x00, 0x00, 0x00,
	/* [97] 9 bmaControls(1) : 0x00000000 */ 0x00, 0x00, 0x00, 0x00,
	/* [101] 13 bmaControls(1) : 0x00000000 */ 0x00, 0x00, 0x00, 0x00,
	/* [105]. iFeature */ 0,
	/* ----- Audio 2.0 AC Output Terminal Descriptor */
	/* [106] 0 bLength */ 12,
	/* [107] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x03,
	/* [109] 3 bTerminalID */ 0x14,
	/* [110] 4 wTerminalType : 0x0301 (Speaker) */ 0x01, 0x03,
	/* [112] 6 bAssocTerminal, bSourceID, bCSourceID */ 0x00, 0x16, 0x18,
	/* [115] 9 bmControls, iTerminal */ 0x00, 0x00, 0,
	/* ------ Audio 2.0 AC 2nd Input Terminal Descriptor */
	/* [118] 0 bLength */ 17,
	/* [119] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x02,
	/* [121] 3 bTerminalID */ 0x20,
	/* [122] 4 wTerminalType : 0x0102 (Microphone) */ 0x01, 0x02,
	/* [124] 6 bAssocTerminal, bCSourceID */ 0x00, 0x18,
	/* [126] 8 bNrChannels */ 2,
	/* [127] 9 bmChannelConfig */ 0x03, 0x00, 0x00, 0x00,
	/* [131] 13 iChannelNames, bmControls, iTerminal */ 0, 0x00, 0x00, 0,
	  /* ----- Audio 2.0 AC 2nd Output Terminal Descriptor */
	/* [135] 0 bLength */ 12,
	/* [136] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x03,
	/* [138] 3 bTerminalID */ 0x22,
	/* [139] 4 wTerminalType : 0x0101 (USB Streaming) */ 0x01, 0x01,
	/* [141] 6 bAssocTerminal, bSourceID, bCSourceID */ 0x00, 0x20, 0x18,
	/* [144] 9 bmControls, iTerminal */ 0x00, 0x00, 0,
	/* --- Interface Descriptor #1: Stream OUT (9+9+16+6+7+8=55) */
	/* [147] 0 bLength, bDescriptorType */ 9, 0x04,
	/* [149] 2 bInterfaceNumber, bAlternateSetting */ 1, 0,
	/* [151] 4 bNumEndpoints */ 0,
	/* [152] 5 bInterfaceClass : 0x01 (Audio) */ 0x01,
	/* [153] 6 bInterfaceSubClass : 0x01 (AudioStream) */ 0x02,
	/* [154] 7 bInterfaceProtocol : 0x20 (VERSION_02_00) */ 0x20,
	/* [155] 8 iInterface */ 0,
	/* ----------------------- Interface Descriptor */
	/* [156] 0 bLength, bDescriptorType */ 9, 0x04,
	/* [158] 2 bInterfaceNumber, bAlternateSetting */ 1, 1,
	/* [160] 4 bNumEndpoints */ 1,
	/* [161] 5 bInterfaceClass : 0x01 (Audio) */ 0x01,
	/* [162] 6 bInterfaceSubClass : 0x01 (AudioStream) */ 0x02,
	/* [163] 7 bInterfaceProtocol : 0x20 (VERSION_02_00) */ 0x20,
	/* [164] 8 iInterface */ 0,
	/* ----------- Audio 2.0 AS Interface Descriptor */
	/* [165] 0 bLength */ 16,
	/* [166] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x01,
	/* [168] 3 bTerminalLink, bmControls */ 0x12, 0x00,
	/* [170] 5 bFormatType : 0x01 (FORMAT_TYPE_I) */ 0x01,
	/* [171] 6 bmFormats : 0x000000001 (PCM) */ 0x01, 0x00, 0x00, 0x00,
	/* [175] 10 bNrChannels */ 2,
	/* [176] 11 bmChannelConfig */ 0x03, 0x00, 0x00, 0x00,
	/* [180] 15 iChannelNames */ 0,
	/* --------- Audio 2.0 AS Format Type Descriptor */
	/* [181] 0 bLength */ 6,
	/* [182] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x02,
	/* [184] 3 bFormatType : 0x01 (FORMAT_TYPE_I) */ 0x01,
	/* [185] 4 bSubslotSize, bBitResolution */ 2, 16,
	/* ------------------------- Endpoint Descriptor */
	/* [187] 0 bLength, bDescriptorType */ 7, 0x05,
	/* [189] 2 bEndpointAddress */ 0x01,
	/* [190] 3 bmAttributes : 0x0D (Sync|ISO) */ 0x0D,
	/* [191] 4 wMaxPacketSize : 0x0100 (256) */ 0xC0, 0x00,
	/* [193] 6 bInterval : 0x04 (1ms) */ 4,
	/* - Audio 2.0 AS ISO Audio Data Endpoint Descriptor */
	/* [194] 0 bLength */ 8,
	/* [195] 1 bDescriptorType, bDescriptorSubtype */ 0x25, 0x01,
	/* [197] 3 bmAttributes, bmControls */ 0x00, 0x00,
	/* [199] 5 bLockDelayUnits, wLockDelay */ 0x00, 0x00, 0x00,
	/* --- Interface Descriptor #1: Stream IN Mic (9+9+16+6+7+8=55) */
	/* [202] 0 bLength, bDescriptorType */ 9, 0x04,
	/* [204] 2 bInterfaceNumber, bAlternateSetting */ 2, 0,
	/* [206] 4 bNumEndpoints */ 0,
	/* [207] 5 bInterfaceClass : 0x01 (Audio) */ 0x01,
	/* [208] 6 bInterfaceSubClass : 0x01 (AudioStream) */ 0x02,
	/* [209] 7 bInterfaceProtocol : 0x20 (VERSION_02_00) */ 0x20,
	/* [210] 8 iInterface */ 0,
	/* ----------------------- Interface Descriptor */
	/* [211] 0 bLength, bDescriptorType */ 9, 0x04,
	/* [213] 2 bInterfaceNumber, bAlternateSetting */ 2, 1,
	/* [215] 4 bNumEndpoints */ 1,
	/* [216] 5 bInterfaceClass : 0x01 (Audio) */ 0x01,
	/* [217] 6 bInterfaceSubClass : 0x01 (AudioStream) */ 0x02,
	/* [218] 7 bInterfaceProtocol : 0x20 (VERSION_02_00) */ 0x20,
	/* [219] 8 iInterface */ 0,
	/* ----------- Audio 2.0 AS Interface Descriptor */
	/* [220] 0 bLength */ 16,
	/* [221] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x01,
	/* [223] 3 bTerminalLink, bmControls */ 0x22, 0x05,
	/* [225] 5 bFormatType : 0x01 (FORMAT_TYPE_I) */ 0x01,
	/* [226] 6 bmFormats : 0x000000001 (PCM) */ 0x01, 0x00, 0x00, 0x00,
	/* [230] 10 bNrChannels */ 2,
	/* [231] 11 bmChannelConfig */ 0x03, 0x00, 0x00, 0x00,
	/* [235] 15 iChannelNames */ 0,
	/* --------- Audio 2.0 AS Format Type Descriptor */
	/* [236] 0 bLength */ 6,
	/* [227] 1 bDescriptorType, bDescriptorSubtype */ 0x24, 0x02,
	/* [239] 3 bFormatType : 0x01 (FORMAT_TYPE_I) */ 0x01,
	/* [240] 4 bSubslotSize, bBitResolution */ 2, 16,
	/* ------------------------- Endpoint Descriptor */
	/* [242] 0 bLength, bDescriptorType */ 7, 0x05,
	/* [244] 2 bEndpointAddress */ 0x83,
	/* [245] 3 bmAttributes : 0x0D (Sync|ISO) */ 0x0D,
	/* [246] 4 wMaxPacketSize : 0xC0 (48kHz * 2 channels * 2 bytes width) */ 0xC0, 0x00,
	/* [248] 6 bInterval : 0x04 (1ms) */ 0x4,
	/* - Audio 2.0 AS ISO Audio Data Endpoint Descriptor */
	/* [249] 0 bLength */ 8,
	/* [250] 1 bDescriptorType, bDescriptorSubtype */ 0x25, 0x01,
	/* [252] 3 bmAttributes, bmControls */ 0x00, 0x00,
	/* [254] 5 bLockDelayUnits, wLockDelay */ 0x00, 0x00, 0x00,
Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
331 questions
{count} votes

Accepted answer
  1. Chaoqiong Xiao 486 Reputation points Microsoft Employee
    2023-09-05T03:11:26.02+00:00

    @Serhii Cherkasov The data endpoint for USB Audio must be isochronous endpoint, interrupt endpoint does not work.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.