• AVR Freaks

LockedHow to make USB faster with 18F4550?

Author
Guest
Super Member
  • Total Posts : 80503
  • Reward points : 0
  • Joined: 2003/01/01 00:00:00
  • Location: 0
  • Status: online
2006/05/26 08:49:47 (permalink)
0

How to make USB faster with 18F4550?

Hi, Since USB 2.0 specification allows only 64 bytes data packets for full speed, communication is very slow.   I use data packets of size 512 bytes.  It works on the most of computers, but on some, especially on new ones does not.  So I can transfer about 64kB/s when using 64 bytes and 512kB/s when 512 bytes packet.  That is big different.  Does not anyone have ID, how to speed-up communication on all computers according to USB 2.0 specification? How to send more than 1000 packets in one sec?
 
Thanks, Koci
#1

16 Replies Related Threads

    Pacer
    Super Member
    • Total Posts : 1171
    • Reward points : 0
    • Joined: 2004/12/01 09:29:20
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/26 10:24:23 (permalink)
    0
    how to speed-up communication on all computers according to USB 2.0 specification?

    Unless you are using isochronous transfers, then the USB specification does not guarantee any particular throughput rate.
     
    What sort of transfers are you using? Bulk?
     
    What particular operating systems (or USB controller types) do you think are slower?
     
    To really know where the problem is you need to examine the packets on the bus, and see where the delay arises.
     
    Are you using ping-pong yet? This is the final tool for ultimate throughput (if you can get it to work!).
    #2
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/05/26 15:51:54 (permalink)
    0
    Yes, I am using bulk transfer. I set up packet size for 512 bytes.  It works on the most computers, but does not work for example on XP - gForce 610 chipset. It does not accepts packets greater than 128 bytes.  In USB specification is written, than I should use maximum 64 bytes packets for bulk transfer.  I am not using ping-pong yet, but I send almost all data from device to host packet by packet.  Do you think, ping-pong will make it faster? Anyway, if does, it makes 2x faster, so it is not much if I use only 64 bytes packet.

    aspforum.mchp.guest
    #3
    Pacer
    Super Member
    • Total Posts : 1171
    • Reward points : 0
    • Joined: 2004/12/01 09:29:20
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/27 01:20:01 (permalink)
    0
    OK - now I'm confused. I should have asked what driver you are using as I assumed you were using the one supplied by Microchip.
     
    In USB specification is written, than I should use maximum 64 bytes packets for bulk transfer.
    Yes, but this is on the bus. When you request a larger block of data, say 2048 bytes, the driver will pass the request to the usbd.sys driver which will split the request up into 64 byte packets. Provided you fill all the packets you send with the full 64 bytes, then you will receive, from the driver you are talking to, the full 2048 bytes in one request. This is the first and easiest way to go faster. If this is not working for you then that is what you should be investigating. I know of no reason, per se, that XP should not support this.
     
    By the way I assume you didn't mean that your descriptor specifies 512 bytes per packet? That would be illegal of course.
    #4
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/05/27 03:20:46 (permalink)
    0
    Yes, I am using Microchip driver or LibUSB driver. 
    I set length of data in Endpoint descriptor to 0x220.
    I set buffer data length in buffer BDnCNT to 0x200, fill the buffer and everything works, send request to read 0x200 bytes of data and everything works on most of the computers. 

    But how to read data if I set data in Endpoint descriptor only to 0x40 bytes? If I set data data in EP descriptor to 0x40, and set length in buffer BDnCNT to 0x200 and send request to read 0x200 or 0x40 I get error.  What I am doing wrong?  Should I set BDnCNT to only 0x40 and send request to read 0x200 and set 8 times data to BD buffer?

    Thank you.
    post edited by Koci - 2006/05/27 03:22:04
    #5
    Pacer
    Super Member
    • Total Posts : 1171
    • Reward points : 0
    • Joined: 2004/12/01 09:29:20
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/27 04:42:37 (permalink)
    0
    Yes, I am using Microchip driver or LibUSB driver. 
    I set length of data in Endpoint descriptor to 0x220.
    I set buffer data length in buffer BDnCNT to 0x200, fill the buffer and everything works, send request to read 0x200 bytes of data and everything works on most of the computers. 

    That really surprises me. But it is really surprising that it works at all, because the host really ought to reject an illegal device. I think hosts often put up with some errors, because there are so many faulty devices around (on sale).

    But how to read data if I set data in Endpoint descriptor only to 0x40 bytes? If I set data data in EP descriptor to 0x40, and set length in buffer BDnCNT to 0x200 and send request to read 0x200 or 0x40 I get error.  What I am doing wrong? 

    See below. 
     
    Should I set BDnCNT to only 0x40 and send request to read 0x200 and set 8 times data to BD buffer?

    Yes, that's exactly what you should be doing.
    #6
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/05/27 05:09:32 (permalink)
    0
     
    quote:

    Should I set BDnCNT to only 0x40 and send request to read 0x200 and set 8 times data to BD buffer?


    Yes, that's exactly what you should be doing.


     
    But this does not work to me at least with MCHPUSB or LibUSB drivers. If I set buffer only BDnCNT to 0x40 and call function ReceivePacket with request to receive 0x200 does not work.
    When sending data from device to host, I set up data in BDbuffer and in BDnSTAT change DTS (data0/data1) and set UOWN to USB and DTSEN (data togle synchronization) and then I wait until BDnSTAT  UOWN is not set to PIC. Then I will fill buffer with new data and repeat this procedure. Is this procedure OK? I need to know, if search bug in this procedure or in driver.
     
    Thank you.

    aspforum.mchp.guest
    #7
    Pacer
    Super Member
    • Total Posts : 1171
    • Reward points : 0
    • Joined: 2004/12/01 09:29:20
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/27 06:03:53 (permalink)
    0
    I never looked at libusb myself, but MCHPUSB doesn't have a function called ReceivePacket.It looks like MPUSBRead is the function you would be using to read multiple packets in one go.
     
    ReceivePacket may be badly named but sounds like is would only receive a packet at a time, rather than a larger block of several packets.
     
    When sending data from device to host, I set up data in BDbuffer and in BDnSTAT change DTS (data0/data1) and set UOWN to USB and DTSEN (data togle synchronization) and then I wait until BDnSTAT  UOWN is not set to PIC. Then I will fill buffer with new data and repeat this procedure. Is this procedure OK? I need to know, if search bug in this procedure or in driver.
    At a quick glance that seems right.
    #8
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/05/27 06:24:21 (permalink)
    0
    Yes, I use MPUSBRead with MCHPUSB, but same result.  I will make more tests.  Thanks for help so far.
     
    So you think, that if I use MPUSBRead(myInPipe,ReceiveData, ExpectedReceiveLength,ReceiveLength,ReceiveDelay), where I put ReceiveLength for example 512 bytes, will work if I set 8 times new data in BD buffer of size 64 bytes? Probably I have bug in FW, I will check.  Thank you again.

    Koci
    post edited by Koci - 2006/05/27 06:31:16
    #9
    Pacer
    Super Member
    • Total Posts : 1171
    • Reward points : 0
    • Joined: 2004/12/01 09:29:20
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/27 06:47:39 (permalink)
    0
    So you think, that if I use MPUSBRead(myInPipe,ReceiveData, ExpectedReceiveLength,ReceiveLength,ReceiveDelay), where I put ReceiveLength for example 512 bytes, will work if I set 8 times new data in BD buffer of size 64 bytes?
    That's what I believe. I am fairly sure that several other people around this forum have already done just that.
     
     
    Probably I have bug in FW, I will check.
    Yeah, probably, Try reading 64 bytes first, if that works you have a clue. If it doesn't then you have a different clue. I would have said, be careful with data toggle, but you sound like you already are.
    #10
    hwti
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2005/06/20 09:26:12
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/27 07:33:42 (permalink)
    0
    It seems you can use >64byte packets with UHCI USB controllers, but it doesn't work with OHCI controllers

    USB is usually slow because of the drivers : they use only one IRP. Transfer is only done at the first frame after the IRP is sent, and the IRP is only restarted after is it completed, so we have only one transfer per frame, so 64KB/s is the best case
    - libusb uses only one IRP
    - microchip and microsoft "usbser.sys" driver seem to use only one IRP

    You need to use other drivers : I can get about 600KB/s (speed limited by the PIC, if I it isn't at 48Mhz, it is slower) without ping-pong buffering
    post edited by hwti - 2006/05/29 03:31:00
    #11
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/05/27 07:59:07 (permalink)
    0
    Thank you Pacer, you are a king. Now everything working OK with MPUSBRead.  I forgot to set first packet to maximum data size specified in Endpoint descriptor (64).  If packet is smaller, MPUSBRead does not read more data. 

    aspforum.mchp.guest
    #12
    Pacer
    Super Member
    • Total Posts : 1171
    • Reward points : 0
    • Joined: 2004/12/01 09:29:20
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/27 08:30:49 (permalink)
    0
    Glad it's working! It would no doubt be helpful to others reading this if you could post some information about the speed you achieve.
    #13
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/05/27 09:58:05 (permalink)
    0
    The speed I achieved is only 256kB/s (without ping-pong), but still better than 64. I can read data safely only about 300 bytes in one step with MPUSBRead, so I set it to 256 bytes. If I try to read for example 512 bytes, it reads only 192 or 256 or 300 bytes.
    #14
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/05/28 06:27:27 (permalink)
    0
    ORIGINAL: hwti

    It seems you can use >64byte packets with UHCI USB controllers, but it doesn't work with OHCI controllers

    USB is usually slow because of the drivers : they use only one IRP. Transfer is only done at the first frame after the IRP is sent, and the IRP is only restarted after is it completed, so we have only one transfer per frame, so 64Ko/s is the best case
    - libusb uses only one IRP
    - microchip and microsoft "usbser.sys" driver seem to use only one IRP

    You need to use other drivers : I can get about 600Ko/s (speed limited by the PIC, if I it isn't at 48Mhz, it is slower) without ping-pong buffering

     
    What drives do you use to get 600kB/s without Ping-Pong?

    aspforum.mchp.guest
    #15
    hwti
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2005/06/20 09:26:12
    • Status: offline
    RE: How to make USB faster with 18F4550? 2006/05/29 03:46:25 (permalink)
    0
    I use a firmware based on bminch assembler one, but interrupt-driven. I use software double-buffering (easier than ping-pong buffering) : when the SIE owns buffer1, I can fill buffer2, and after the packet is transmitted, I can change the USB buffer address to buffer2.

    I wrote a custom driver based on microsoft sample drivers : isousb (how to use multiple IRPs) and bulkusb.
    It is a basic (not all features programmed) virtual COM port driver. With many IRPs, I can get a great speed even with packets smaller than the maximum packet size.
    And it tries to read data as soon as its buffer isn't full, so speed depends less on the size of the requests done by the application.

    I can get about 600KB/s (or even more, it depends what time the PIC spends to get data to send (buffer to copy, or code memory to read, ...)
    post edited by hwti - 2006/05/29 03:48:03
    #16
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: How to make USB faster with 18F4550? 2006/06/06 14:46:57 (permalink)
    0
    Could you tell me your 600b is 600byte or 600bit? I can only get about 500kbit/second. I need more than 3Mbit/second. I have done a lot test on PICDEM FS USB. I tried interupt and bulk mode. I also put another pair of end points into the firmware, but still I can only get 500kbit/second.
     
    Please give me some idea what I should do next.
     
    Thanks,
     
    Frank
    #17
    Jump to:
    © 2020 APG vNext Commercial Version 4.5