Skip to main content
Visitor II
May 13, 2020
Question

STM32 delay not working as expected with USB HID

  • May 13, 2020
  • 2 replies
  • 698 views

I am trying to send a shift + U keypress to the screen every two seconds but it is just printing U's nonstop. Why isn't it delaying for two seconds? How do I properly debug stuff like this in the future?

 while (1)
 {
	 hid_report_buffer[0] = 0x02; //0b00000010;
	 hid_report_buffer[2] = 0x18;
	 USBD_HID_SendReport(&hUsbDeviceFS, hid_report_buffer, 8);
 
	 hid_report_buffer[0] = 0x00; //0b00000000;
	 hid_report_buffer[2] = 0x00;
	 USBD_HID_SendReport(&hUsbDeviceFS, hid_report_buffer, 8);
 
 
	 HAL_Delay(2000);
 
 /* USER CODE END WHILE */
 
 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}

    This topic has been closed for replies.

    2 replies

    Super User
    May 13, 2020

    Because the "release" code probably does not get on the wire. Can you see why?

    -- pa

    JMora.2Author
    Visitor II
    May 13, 2020

    I think it is because of the polling interval on the host. It works when I insert a delay larger than the polling interval. But I am still confused as why the delay is not being hit at all in the first case.