2019-06-25 12:23 AM
Hi, I'm using an stm32f102 for making usb game controller (custom hid) with 29 buttons. The problem is, that the latency if I check on PC is feelable, too high. I made some tests to figure out the problem, but I don't have any idea yet. If I just report continiusly in the main while with 50ms delays, the indicator led on game controller window on pc just blinks with ~1s. So, seems, don't receive all of the data. If I increase this delay to 100ms it looks almost fine. I tried also to measure latency with camera (measure the time between click sound and the indicator on pc screen). For STM32 was around 5-6 frame with 30fps. I tried also with a good working game controller, it is 2-3 frame. If I report with every 1ms from systick, it's not better. I looked into the send report function and experienced, that the function sometimes returns with busy, even if data send is with 50ms interval. Why? :o In the MCU runs everything on 48MHz and in the test is just a gpio read and report. Any idea?
2019-06-25 01:44 PM
I found finally the "bInterval" in the USB descriptor. If I change it to 1, the polling interval will be 10ms (checked with usb analyzer). But why not 1ms? It's not possible? Earlier was 64ms.
2019-06-25 04:42 PM
Polling interval for full speed devices (the case for STM32F0) is in milliseconds. So, value 1 means 1 ms.
However, the host can ignore your interval value and use any other.
-- pa
2019-07-02 10:57 AM
As I recall, the USB HID device class uses primarily "Interrupt" type USB transactions/endpoints. Interrupt endpoints have a guaranteed polling rate that is specified by the bInterval field in the device descriptor, as you noted. The minimum bInterval as stated in the USB specification (for low and full speed devices, at least) is 10mS.
A 10mS polling/update rate works out to a maximum latency of 3.3 frames @ 30 FPS, which is consistent with the response you measured when using your "good working game controller".
I'm not sure how HID-compatible (gaming) devices that claim to support update rates in excess of 100x/s achieve this; I can only guess as I've never put any such on a USB analyzer, but I suspect that they support alternate configurations or interfaces that are non-HID and vendor specific, as using bulk or isochronous endpoints would be the only way I know of to achieve that sort of update rate.
2024-09-23 12:32 AM
I’ve also experienced high latency with USB HID controllers on STM32. Adjusting the USB polling rate and optimizing interrupt handling helped reduce lag in my case. It would be great to see if those adjustments work for you too. For anyone interested in gaming hardware performance.