This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377D: USB bulk transfer priority

Part Number: TMS320F28377D

Hi,

I am working with the TMS320F28377D and I have connected a USB cable to it. I have used the USB bulk examples and modified the code on the microcontroller as well as the Visual Studio code. I am currently sampling the ADC and transferring the data to the computer. Using an oscilloscope, I am seeing that the sampling rate is very consistent, but the USB data transfer is not. Most times, it is able to transfer the data fast enough (where the data is a 64-byte packet, 64x8-bit, which means 32 16-bit ADC samples), but sometimes the data transfer takes too long and samples are lost. Is there a way to make the USB priority in Visual Studio? Or any changes I can make to the microcontroller code to have the USB transfer be more reliable?

Thank you,

Dyon 

  • Hi Dyon,

    How have you written the ADC samples to USB buffer + TX process? Is the execution time for this process consistent at all times? Can check using the profiling clock in CCS (count CPU cycles).

    I'll request our USB SW expert to provide further comments.

    Best,

    Kevin

  • Hi Kevin,

    Basically, I am using the following code:

    void sendData(){
    do{
    ui32Space = USBDBulkTxPacketAvailable(&g_sBulkDevice);
    }while(ui32Space!=BUFFER_SIZE);

    USBDBulkPacketWrite(&g_sBulkDevice, resultBuffer, ui32Space, true);
    }

    What I am trying to do here is write a packet when the bus is clear. This is the part that is inconsistent I believe. I think it has to do with the bus being busy when it wants to write a new packet. So I think the issue lies with the computer. I need to somehow set the priority level on the computer so that it reads of the bus fast enough. 

    In Visual Studio, I am using this line:  dwError = ReadUSBPacket(hUSB, szBuffer, USB_BUFFER_LEN, &ulRead, 5000, NULL);

    The whole communication works, it is just not consistent in getting the data of the bus fast enough. When I have other programs open on my computer, it becomes even worst, which is to be expected. Which is why I think it has to do with priority levels. 

    - Dyon

  • Dyon, 

    Did you try setting higher priority to the windows process that runs the VC++ application? 

    USB is not really a good real-time communication peripheral/protocol. 

    See this thread 

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/586463/tms320f28377d-usb-bulk-transfer-max-rate

    Best Regards

    Siddharth

  • Siddharth,

    I am trying to figure out how to set higher priority, but I am not sure how to do it. 

    As for USB not being a good real-time communication peripheral/protocol, do you have a suggestion for another protocol that can do at least 5Mbps and can easily be connected to any laptop? Most computers now only have USB. 

    - Dyon

  • Dyon, 

    Computers now only have USBs and seems to the right choice, however even we haven't been able to achieve the full speed of 12 Mbps . We have been able to achieve 7-8 Mbps. The limiting factor in that case was not the CPU utilization or USB module on the device, but rather the DATA IN requests from the PC.

    Can you try setting the priority of the process in the windows task manager to "realtime"?

    Best Regards

    Siddharth

  • Siddharth,

    Isn't setting the priority level to realtime risky? I will try to set the priority level to high priority first and if that doesn't work, I will try realtime priority. I will give an update on how that goes.

    Dyon

  • Dyon, 

    Please try it out and let me know your observations.

    Best Regards

    Siddharth

  • Siddharth,

    I tried it, and no luck. Not with 'high priority' nor with 'realtime priority'. It might be with the microcontroller. I need to change that code somehow. Is there a buffer for the USB packets, that I can add to when I have new data and the USB will send one after the other as fast as it can? because now, if one transmission takes longer than my sampling, I lose that set of samples. But if I can store them in a buffer where the USB can just send it once it is done, it might be able to send multiple packets between samples? (with samples I mean 64 bytes/1 packet worth).

    Dyon 

  • Dyon, 

    I think you can try increasing the buffer size (BULK_BUFFER_SIZE) .

    Best Regards

    Siddharth

  • Siddharth,

    What would changing the buffer size (BULK_BUFFER_SIZE) do? As I understand it, no more than 64 Bytes can be sent at a time. I am assuming the buffer you are referring to is the send buffer?

    Dyon

  • Siddharth,

    I now believe it has to do with the computer capabilities. I kept not being able to transmit packets fast enough with a laptop I was using with 2 cores and Windows 10. Then I tested with a computer with 8 cores and Windows 7 and there is almost no packet loss at all. I just don't know if it is the operating system or the processor. The WinUSB should be compatible with all Windows OS systems, correct?

    Any suggestions regarding this issue?

    Thanks,

    Dyon 

  • Dyon, 

    Glad that you were able to narrow it down to PC side.

    I think it's better to check with Windows/Microsoft forum regarding this. As far as I know, WinUSB should be compatible with versions of Windows.

    Best Regards

    Siddharth