• AVR Freaks

USB HID report size greater than 64 bytes with Microchip Stack

Author
govind_mukundan
Super Member
  • Total Posts : 188
  • Reward points : 0
  • Joined: 2009/05/12 23:50:07
  • Location: singapore/india
  • Status: offline
2013/05/27 19:42:39 (permalink)
0

USB HID report size greater than 64 bytes with Microchip Stack

Hi All,
 
I am developing an application where I am using the USB HID class to transfer some data from my device to a Host (PC, mobile ...). I have modified the microchip HID custom demo to be able to transfer data using a Request - Response type protocol, and it works. But there are cases when I want to send some big chunks of data like a small file (~KB). At the moment my protocol can only send data in chunks of 64 bytes each (report size = 64), and for each 64 byte chunk the host issues a request, so it ends up being relatively slow. I can think of two things to improve the speed:
 
1. Transfer the whole file continuously as 64 byte chunks without the host having to specifically request for each 64 byte chunk. I tried doing this by sending data whenever the
HIDTxHandleBusy(USBInHandle)

returns FALSE. But once I sent two packets, the handle was always busy.
My logic is that once the host has read from the IN_EP, the handle is free and I can write another IN packet to the host. I am not sure what I am doing wrong here, could anyone help me out?
 
2.  Send a HID Report with more than 64 bytes, splitting it into multiple 64 byte transactions. But I am not sure how such a transaction is handled by the microchip USB stack, right now it looks like it only supports 64 byte reports? Is that correct?
 
Thanks!
Govind
#1

4 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:USB HID report size greater than 64 bytes with Microchip Stack 2013/05/28 00:16:16 (permalink)
    0
    With HID, the max size is 64bytes and if using Interrupt Endpoints you will get a maximum of 1000 of them per second.
     
    To make it faster, you should use Bulk endpoint and tweak the code a bit (especially at PC side) - search this forum for that!

    GENOVA :D :D ! GODO
    #2
    govind_mukundan
    Super Member
    • Total Posts : 188
    • Reward points : 0
    • Joined: 2009/05/12 23:50:07
    • Location: singapore/india
    • Status: offline
    Re:USB HID report size greater than 64 bytes with Microchip Stack 2013/05/28 03:10:36 (permalink)
    0
    Hi Dario,
     
    Thanks for your reply. I didn't know that you could use bulk transfers with HID, but I think that it may not be required for my application. My file size is around 38kB, and if I can transfer that file in about 3s, it should be enough. Right now I seem to have a problem getting the proper throughput for HID interrupt transfers. I will explain the code in a bit more detail, the working flow is like this:
     
    loop_start
    1. Host sends Request_File_Report command on the OUT_EP
    2. Device receives it, reads 64 bytes from the file and puts it on the IN_EP, until the EOF.
    loop_end

    I want to modify this so that it is like this:
     
    1. Host sends Request_File_Report command on the OUT_EP
    2. Device receives it, enters the below loop
    loop_start
    if(HIDTxHandleBusy(USBInHandle) == FALSE ) //IN_EP is free to write?
    {
    3. Device reads 64 bytes from the file and puts it on the IN_EP, until the EOF.
    }
    loop_end

     
    This modification does not work, the Tx handle becomes busy after the 2nd report transfer. So I'm not sure if there is something wrong in my logic for the device code or it is related to the PC application not processing the HID IN packets fast enough..
    post edited by govind_mukundan - 2013/05/28 03:13:17
    #3
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:USB HID report size greater than 64 bytes with Microchip Stack 2013/05/28 08:22:13 (permalink)
    0
    Hmm, you're still using Interrupt EPs?
    Then, you won't get any improvement using that type of code (and actually I seem to remember that it's not the proper way for bulk ones as well)..

    GENOVA :D :D ! GODO
    #4
    natraj20
    Junior Member
    • Total Posts : 103
    • Reward points : 0
    • Joined: 2010/10/20 09:43:47
    • Location: 0
    • Status: offline
    Re:USB HID report size greater than 64 bytes with Microchip Stack 2013/05/28 12:38:36 (permalink)
    +2 (1)
    I believe one iteration in your loop is considered a single usb transaction and 64 bytes is the best you can in a single transaction (1 ms) in HID Interrupt EPs.  You can implement the loop for maintaining data packet sequences but you cannot improve the buffering higher than 64 bytes using Interrupt EPs as Dario said.
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5