Hot!USB CDC throttling.

Author
vini_i
Super Member
  • Total Posts : 398
  • Reward points : 0
  • Joined: 2014/01/16 17:51:55
  • Location: Ohio, United States
  • Status: offline
2018/07/12 03:05:33 (permalink)
0

USB CDC throttling.

I set up a USB stack for CDC using Harmony. It works well if I'm sending the data slowly. I want to try sending data as fast as I can. When doing this I overflow the queue buffer. The USB_DEVICE_CDC_Write function returns the following error, USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL. 
 
Is there a designated or acceptable way to monitor the current queue level and throttle the data accordingly so that the queue does not overflow?
#1

8 Replies Related Threads

    Antipodean
    Super Member
    • Total Posts : 1647
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: online
    Re: USB CDC throttling. 2018/07/12 05:26:47 (permalink)
    3 (1)
    Which direction are you sending the data?
     
    What transfer rate are you hoping to achieve? I have achieved very close to the maximum theoretical transfer rate with a PIC24 sending to a PC, but it was under some very specific constraints.
     
     

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #2
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: USB CDC throttling. 2018/07/12 05:57:51 (permalink)
    3 (1)
    A post by vini_i has vanished.
    I guess he did not pay attention to the signature of the poster he was answering.
    You can NOT quote his messages. Just the presence of his username in your post will make it vanish!

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #3
    vini_i
    Super Member
    • Total Posts : 398
    • Reward points : 0
    • Joined: 2014/01/16 17:51:55
    • Location: Ohio, United States
    • Status: offline
    Re: USB CDC throttling. 2018/07/12 06:03:39 (permalink)
    0
    Anti
    Which direction are you sending the data?
     
    What transfer rate are you hoping to achieve? I have achieved very close to the maximum theoretical transfer rate with a PIC24 sending to a PC, but it was under some very specific constraints.


    The data is being sent from the chip to a PC. The chip is enumerated as high-speed USB. 
     
    I'm looking to get about 1 megabit a second continuous transfer speed. Maybe 1.2 for a bit of overhead. It does not bother me if the data is sent in bursts as long as it arrives in order. 
     
    My understanding is that with USB to serial devices such as FTDI the serial part is what holds back the speed. If the data is sent directly by the chip through the USB link that much higher speeds are possible. 
     
    I'm trying to test what the actual maximum speed of the link is. 
    #4
    vini_i
    Super Member
    • Total Posts : 398
    • Reward points : 0
    • Joined: 2014/01/16 17:51:55
    • Location: Ohio, United States
    • Status: offline
    Re: USB CDC throttling. 2018/07/12 06:05:19 (permalink)
    0
    q
    A post by vini_i has vanished.
    I guess he did not pay attention to the signature of the poster he was answering.
    You can NOT quote his messages. Just the presence of his username in your post will make it vanish!



    You are correct. I caught that only after I posted. OOPS.
    #5
    Antipodean
    Super Member
    • Total Posts : 1647
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: online
    Re: USB CDC throttling. 2018/07/12 06:16:05 (permalink)
    4 (1)
    vini_i
    Anti
    Which direction are you sending the data?
     
    What transfer rate are you hoping to achieve? I have achieved very close to the maximum theoretical transfer rate with a PIC24 sending to a PC, but it was under some very specific constraints.


    The data is being sent from the chip to a PC. The chip is enumerated as high-speed USB. 
     
    I'm looking to get about 1 megabit a second continuous transfer speed. Maybe 1.2 for a bit of overhead. It does not bother me if the data is sent in bursts as long as it arrives in order. 
     
    My understanding is that with USB to serial devices such as FTDI the serial part is what holds back the speed. If the data is sent directly by the chip through the USB link that much higher speeds are possible. 
     
    I'm trying to test what the actual maximum speed of the link is. 





    The maximum CDC speed is about 1.5Mbytes/sec IIRC.
     
    On the PIC24 I increased the buffer size so that I could preload it with the maximum number of bytes that will fit a single USB transfer (I can't remember how many 64 byte packets that is, but seem to recall it is around 19, but I may be wrong). Then I had a program looping filling the buffer with data, the first 4 or 5 characters were a 'line number' so I could see if any data went missing. Then using a laptop with a dual core processor it would receive the data (I used a terminal program to display it on the screen) but it would always have errors about once a minute or so. I then used my 4 core processor to receive the data with a terminal program and that would receive without errors - until th screen saver kicked in, and then there would be breaks in the received data.
     
    So to get the speed you want you will need a pretty good PC at the other end to get anywhere near the maximum possible speed continuously. Then your speed is probably going to be limited by the rate at which your PIC can handle it and stuff it in a buffer. I used ping-pong buffers to get the speed so I was filling one while the other transmitted.
     
    If you are not familiar with the inner workings of USB and how much data and at what speed, then get yourself a copy of "USB Complete" by Jan Axelson. She has written a very readable book that comprehensively expalins the inner working of USB. Available at Amazon for a reasonable price.
     
     

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #6
    vini_i
    Super Member
    • Total Posts : 398
    • Reward points : 0
    • Joined: 2014/01/16 17:51:55
    • Location: Ohio, United States
    • Status: offline
    Re: USB CDC throttling. 2018/07/12 07:58:46 (permalink)
    0
    Alan,
     
    That is exactly what I'm trying to do. What I run in to is I overflow the outgoing USB buffer (USB_DEVICE_CDC_RESULT_ERROR_TRANSFER_QUEUE_FULL). I'm asking if there is any way to monitor the outgoing buffer to keep it from overflowing?
    #7
    jandle
    New Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2017/05/27 06:57:30
    • Location: 0
    • Status: offline
    Re: USB CDC throttling. 2018/07/12 16:56:27 (permalink)
    0
    pretty sure on te PIC32MZ I was able to use 512 byte packets (high speed only, won't work on full speed fallback).  I wasn't trying for speed in that case, but for unfragmented 512 byte blocks...
     
    I do have an application between a Sitarra (Beaglebone Black derivative) and a PIC32MZ where i will want faster than Mb/s.  It seems that at 512 bytes per packet and 1ms packet slots, the issue is only how fast can you process.
    #8
    Jump to:
    © 2018 APG vNext Commercial Version 4.5