cancel
Showing results for 
Search instead for 
Did you mean: 

CDC Communication Issue with HID report data size

Ashvin Ramani
Associate III

Hello @st,

I am working with STM32L4 MCU with the custom board where I enable composite HID + CDC interface on USB.

I want to use XMODEM with CDC interface to update firmware and HID to serve my other module like JoyStick, Jog Shuttle, etc.

I am having a CDC Communication issue, when I increase USBD_CUSTOMHID_OUTREPORT_BUF_SIZE to 512 in usbd_customhid.h for the last HID report(for JSON notification) in the below-mentioned report descriptor, CDC Transmission is working okay, but I am getting random data on CDC receiving. 

HID report descriptor looks like below:

//Joy stick top level collection
0x05, 0x01, //USAGE PAGE (Generic Desktop)
0x09, 0x05, //USAGE (Game Pad(0x05)/Joystick(0x04))
0xA1, 0x01, //COLLECTION (Application)
0x85, 0x01, //REPORT ID (0x01)

0x05, 0x01, //USAGE PAGE (Generic Desktop)
0x09, 0x01, //USAGE (Pointer)
0xA1, 0x00, //COLLECTION (Physical)
0x15, 0x00, //LOGICAL_MINIMUM (0)
0x26, 0xFF, 0x00, //LOGICAL_MAXIMUM (255)
0x35, 0x00, //PHYSICAL_MINIMUM (0)
0x46, 0xFF, 0x00, //PHYSICAL_MAXIMUM (255)
0x75, 0x08, //REPORT_SIZE (8)
0x95, 0x03, //REPORT_COUNT (3)
0x09, 0x30, //USAGE (X)
0x09, 0x31, //USAGE (Y)
0x09, 0x35, //USAGE (Rz)
0x81, 0x02, //INPUT (Data, Var, Abs)
0xC0, //END_COLLECTION

0x05, 0x09, //USAGE (Button)
0X19, 0X01, //USAGE_MINIMUM (1)
0x29, 0x02, //USAGE_MAXIMUM (2)
0x15, 0x00, //LOGICAL_MINIMUM (0)
0x25, 0x01, //LOGICAL_MAXIMUM (1)
0x75, 0x01, //REPORT_SIZE (1)
0x95, 0x02, //REPORT_COUNT (2)
0x81, 0x02, //INPUT (Data, Var, Abs)

0x75, 0x06, //REPORT_SIZE (6)
0x95, 0x01, //REPORT_COUNT (1)
0x81, 0x01, //INPUT (Constant, Array, Absolute)
0xC0, //END_COLLECTION

//Keyboard top level collection
0x06, 0x00, 0xFF, //USAGE PAGE (Vendor Defined Page 3)
//0x05, 0x01, //USAGE PAGE (Generic Desktop)
0x09, 0x06, //USAGE (Keyboard)
0xA1, 0x01, //COLLECTION (Application)
0x85, 0x02, //REPORT ID (0x2)

0x06, 0x00, 0xFF, //USAGE PAGE (Vendor Defined Page 3)
//0x05, 0x07, //USAGE PAGE (Keyboard / Keypad key codes)
0x19, 0xE0, //USAGE_MINIMUM (Keyboard LeftControl - 224)
0x29, 0xE7, //USAGE_MAXIMUM (Keyboard Right GUI - 231)
0x15, 0x00, //LOGICAL_MINIMUM (0)
0x25, 0x01, //LOGICAL_MAXIMUM (1)
0x75, 0x01, //REPORT_SIZE (1)
0x95, 0x08, //REPORT_COUNT (8)
0x81, 0x02, //INPUT (Data, Variable, Absolute) : Modifier byte

0x75, 0x08, //REPORT_SIZE (8)
0x95, 0x01, //REPORT_COUNT (1)
0x81, 0x01, //INPUT (Constant, Array, Absolute) : Reserved byte

0x06, 0x00, 0xFF, //USAGE PAGE (Vendor Defined Page 3)
//0x05, 0x07, //USAGE (Keyboard/Keypad)
0x19, 0x00, //USAGE_MINIMUM (0)
0x29, 0x65, //USAGE_MAXIMUM (101)
0x15, 0x00, //LOGICAL_MINIMUM (0)
0x25, 0x65, //LOGICAL_MAXIMUM (101)
0x75, 0x08, //REPORT_SIZE (8)
0x95, 0x05, //REPORT_COUNT (5)
0x81, 0x00, //INPUT (Data, Array, Absolute) : Key codes
0xC0, //END_COLLECTION

// Jogwheel top level collection
0x06, 0x00, 0xFF, //USAGE PAGE (Vendor Defined Page 4)
//0x05, 0x0C, //USAGE PAGE (Desktop[0x01]/Consumer Control[0x0C]),
0x09, 0x01, //USAGE (Undefined[0x00]/ Consumer [0x01]),
0xA1, 0x01, //COLLECTION (Application),

0x06, 0x00, 0xFF, //USAGE PAGE (Vendor Defined Page 4)
//0x05, 0x01, //USAGE PAGE (Generic Desktop)
0x09, 0x01, //USAGE(Pointer),
0x85, 0x03, //REPORT ID (0x03),
0x15, 0x00, //LOGICAL_MINIMUM (0),
0x25, 0x0A, //LOGICAL_MAXIMUM (10),
0x75, 0x08, //REPORT_SIZE (8),
0x95, 0x05, //REPORT_COUNT (5),
0x81, 0x00, //INPUT (Data, Array, Absolute),

0x05, 0x09, //USAGE (Button),
0x19, 0x01, //USAGE_MINIMUM (1),
0x29, 0x02, //USAGE_MAXIMUM (2)
0x15, 0x00, //LOGICAL_MINIMUM (0)
0x25, 0x01, //LOGICAL_MAXIMUM (1)
0x75, 0x01, //REPORT_SIZE (1)
0x95, 0x02, //REPORT_COUNT (2)
0x81, 0x02, //INPUT (Data, Var, Abs)

0x75, 0x06, //REPORT_SIZE (6)
0x95, 0x01, //REPORT_COUNT (1)
0x81, 0x01, //INPUT (Constant, Array, Absolute)
0xC0, //END_COLLECTION

// JSON Notification
0x06, 0x00, 0xFF, //USAGE PAGE (Vendor Defined Page 1)
0x09, 0x03, //USAGE (Vendor Usage 3)
0xA1, 0x01, //COLLECTION (Application)

0x85, 0x04, //REPORT ID (0x4)
0x15, 0x00, //LOGICAL_MINIMUM (0)
0x26, 0xFF, 0x01, //LOGICAL_MAXIMUM (511)                     
0x75, 0x08, //REPORT_SIZE (8)
0x96, 0xFF, 0x01, //REPORT_COUNT (511)                         
0x09, 0x03, //USAGE (Vendor Usage 3)
0x91, 0x02, //OUTPUT (Data,Variable,Absolute)

0x15, 0x00, //LOGICAL_MINIMUM (0)
0x26, 0xFF, 0x00, //LOGICAL_MAXIMUM (255)
0x75, 0x08, //REPORT_SIZE (8)
0x96, 0xFF, 0x00, //REPORT_COUNT (255)
0x09, 0x03, //USAGE (Vendor Usage 3)
0x81, 0x02, //INPUT (Data,Variable,Absolute)

/* USER CODE END 0 */
0xC0 //END_COLLECTION

But If I keep USBD_CUSTOMHID_OUTREPORT_BUF_SIZE to 448 then both HID and CDC are working okay.

Can you please help here to understand the issue?

5 REPLIES 5
Ashvin Ramani
Associate III

Hello @st, May I have any update on this?

Ashvin Ramani
Associate III

Hello, @st, May I have any update after 9 days? I don't know why there is this much delay in giving a reply

ABOUA
ST Employee

Hello Ashvin,

Could you please specify which STM32L4 you are using? if possible to share the EP FIFO setup?

Thanks

@ABOUA , We are using STM32L4R9ZITX, and following is the EP FIFO information:

HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, (0x83 & 0x7F), 0x80);

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, (0x82 & 0x7F), 0x80); HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, (0x81 & 0x7F), 0x80);

ABOUA
ST Employee

Hello Ashvin,

the shared configuration of EP fifo allocation exceeded the total available fifo size (2K for OTG FS)

as an example for EP3 IN you have allocated (0x80 x 4) --> 128bytes if this EP is for CDC interface it can be set to only 0x40 (64bytes for bulk transfer)

Regards