It just spams the computer with HID packets, each 64 bytes. The second while just wait until the packet is sent.
On PC side, I made a simple application which is receiving all USB HID incoming data and counts time. I used time and data size to calculate transfer speed, and the result is around 65KB/s.
My question is, guys, is this the maximum speed of USB communication that this PIC can do or what I am missing?
Check out the HID protocol spec: https://www.usb.org/developers/hidpage/HID1_11.pdf - Section 5.6 'Reports'.
It states that there can only be one HID transaction per frame and this has a maximum size of 64 bytes. Therefore that is 1 64-byte packet every mSec so you are getting all you can from a HID transfer.
If you want greater throughput then you will need to use other protocols.
Susan