ASF USB HID latency

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am developing a gaming mouse using XMEGA32A4U. USB is setup according to the Atmel app note as full speed and with 48 MHz internal PLL, 24 MHz CPU clock.

 

Using udi_hid_mouse_btnleft(HID_MOUSE_BTN_DOWN), I notice the computer receives the command in about 1-8 ms, somewhat uniformly distributed.

 

So I setup the following experiment. I create a USB composite device on the XMEGA and I send to it a byte using USB CDC. Then in response to the byte, I do one of:

 

1. udi_hid_mouse_btnleft(HID_MOUSE_BTN_DOWN)

2. udi_cdc_putc()

3. Toggle a GPIO which is hooked with a wire to a gaming mouse's button terminal. Then the mouse registers this as a click and sends the mouse down packet to the PC.

 

The roundtrip latencies of the above operations are quite different. As measured on my Windows dev PC,

 

1. is 1-8 ms as I mentioned above.

2. is fairly consistently 1-2 ms.

3. is 2-4 ms.

 

I was particularly surprised that 3 is much faster than 1.

 

Please share tips of why udi_hid_mouse_btnleft() function is that slow? Is it queuing the commands and can I remove that queue? Let me know if you need more info.

 

Thanks!