AnsweredAssumed Answered

STM32F373 usb custom hid. I have encountered a problem.

Question asked by Daniil Zotkin on Dec 20, 2017
Latest reply on Dec 25, 2017 by Ben K

STM32F373 slow usb custom hid cubemx. I have encountered a problem. I can easily configure usb custom hid to work but I can't achieve acceptable speed of usb. I am trying to send array of 1200 bytes. The array should be divided into 64 bytes (bits?) packets. The fact is that the array is transmitted for 20 seconds. It's only 60 bytes per second. It's too far from maximum 1.5 mb/sec. What should I do?

There is my Report descriptor.

__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
  /* USER CODE BEGIN 0 */
  0x06, 0x00, 0xff,      //USAGE_PAGE (Vendor Defined Page 1)
  0x09, 0x01,            //USAGE (Vendor Usage 1)
  0xa1, 0x01,            //COLLECTION (Application)
  0x85, 0x01,              //REPORT_ID (1)
  0x09, 0x01,              //USAGE (Vendor Usage 1)
  0x75, 0x08,              //REPORT_SIZE (8)
  0x96, 0x04, 0xb0,              //REPORT_COUNT (1200)
  0x81, 0x82,              //INPUT (Data,Var,Abs,Vol)
  /* USER CODE END 0 */
  0xC0    /*     END_COLLECTION                  */
};

And I am using FREERTOS and there is my sending thread.

uint8_t dataToSend[0x4b1];

void StartMainT(void const * argument)
{
  /* init code for USB_DEVICE */
  MX_USB_DEVICE_Init();

  /* USER CODE BEGIN 5 */
  TickType_t xLastWakeTime;
  TickType_t xIncrement = 100;
  xLastWakeTime = xTaskGetTickCount();
  /* Infinite loop */
  for(;;)
  {
    vTaskDelayUntil(&xLastWakeTime, xIncrement);
      
    dataToSend[0] = 1;
   
    USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, dataToSend, 0x4b1);
  }
  /* USER CODE END 5 */
}

I am sure that FREERTOS has no influence on usb, because I have tried that config without it and there are no differences.
I have tried to send 21 bytes earlier. Only 2.5 packets/sec were transmitted. It seems that hhid->state is almost always is equal to CUSTOM_HID_BUSY.

Outcomes