cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 delay not working as expected with USB HID

JMora.2
Associate II

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 */
}

2 REPLIES 2
Pavel A.
Evangelist III

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

-- pa

JMora.2
Associate II

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.