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.

USB Bulk Transfer Missing Data

Other Parts Discussed in Thread: TMS320C5515

Hi,

My current project is using the TMS320C5515 in conjunction with CSL 3.04.

The only CSL module I'm using currently in the project is the USB code.

My device enumerates with no issues, but has a problem getting data from the host.

Right now I'm just trying to establish reliable communication between the host and device, so the code in the device is setup to just boomerang back any data it gets from the host.

If I send an even number of bytes from the host to the device, there is no issue.

If I perform 2 transfers from the host to the device that have an odd number of bytes, the second transfer will have the first 2 bytes missing.

When I read how large the transfer was on the device side it is 2 bytes smaller via the method USB_getDataCountReadFromFifo().

For instance, if I send the string "testing" to my device, the second time I send "testing" it will only get "sting".

I'm also having a secondary issue where the device seemingly writes back the data 2 times instead of once, but I have yet to rule out if this issue is on the device or host side.

I based my code off of the USB polling example found in the CSL download, but it has changed since.

Below is my USB section that deals with reading and writing data in the device:

if(pContext->dwIntSourceL & CSL_USB_RX_INT_EP2)

{

// read the RX packet size

// validate the RX packet first

if (USB_isValidDataInFifoOut(&pContext->pEpStatus[CSL_USB_EP2]))

{

// get the EP2 handle

tempEpH = USB_epNumToHandle(hUsbDev, CSL_USB_EP2);

usb_income_num_bytes_ep2 = USB_getDataCountReadFromFifo(tempEpH);

}

else

{

while(1);

}

status = USB_postTransaction(hEp[3], usb_income_num_bytes_ep2, USBDataBufferOut, CSL_USB_OUT_TRANSFER);

if(status != CSL_SOK)

{

while(1);

}

// wait for the RX to be done

while(USB_isTransactionDone(hEp[3], &status) == CSL_USB_FALSE);

status = USB_postTransaction(hEp[2], usb_income_num_bytes_ep2, USBDataBufferOut, CSL_USB_IN_TRANSFER);

if(status != CSL_SOK)

{

while(1);

}

// wait for the TX to be done

while(USB_isTransactionDone(hEp[2], &status) == CSL_USB_FALSE);

}

Any suggestions would be greatly appreciated.

Thanks,

Ben

  • Update:

    I was able to narrow the problem down some more.

    It seems as though that the issue occurs once an uneven number of bytes are sent to the host from the device.

    Example:

    Host sends Device the string "TEST".

    Device gets the string "TEST".

    Device sends host the string "ODD".

    Host gets the string "ODD".

    Host sends device the string "TEST".

    Device gets the string "ST".

    The device will continue to get all future strings from the host with the first 2 bytes missing, but if the device sends an even number of bytes to the host the problem goes away.

    I was able to confirm that the USB peripheral is reporting 2 less bytes received than what was expected.

    Looking at 2189 of file "cls_usbAux.h" is the following code:

    wByteCount = usbRegisters->COUNT0_INDX & 0x1FFF;

    Once the issue occurs the register usbRegisters->COUNT0_INDX is reporting 2 bytes less than what was sent to the device.

    If even numbered transfers are performed the issue isn't present, has anyone else seen this type of behavior before?

    Thanks,

    Ben

  • Update:
    I tested both projects CSL_USB_IntcExample and CSL_USB_PollExample.
    They seem to suffer from a failure that is a little different than mine though.
    Once an odd number of bytes are sent to the device and read back, the next transfer from the device to the host I found to be one of the following:
    - The data is not the same that was sent and is one less byte in size than what was sent.
    - There is no data at all found on the end point.
    - A USB babble error occurs.
    I'm guessing it has something to do with either CSL or the uC at this point.
    I'm going to keep looking into it.
    Thanks,
    Ben
  • Hi Ben, 

     I need few more details from you. 

     1. Can you share the test program and the host side application that were used.This would help us to recreate the same scenario here. 

     2. Was this run on the c5515 EVM or on your custom board. 

     3. With respect to the odd bytes transfers, did you try doing more than two transfers and observe how frequently or in how many read transfers the truncation of data happens ? Is this systematic behavior or random in nature ? what is the transfer length ? 

    Pl let us know on the above. 

    Regards

     Vasanth

  • Hi Vasanth,

    Thanks for the response.

    Below are answers to your questions from perspective of the example projects I ran from TI, and on Spectrum Digitals PCB.

    1. I used the example project CSL_USB_PollExample example found in TI's CLS v3.04, and for the host application the executable found in the link of this Application Report from TI, sprabd7b. I can send the projects as they are on my system, what is the best way?

    2. I did run the CSL_USB_PollExample from CSL v3.04 on the TMX320C5515 eZDSP v2 USB Stick from Spectrum Digital. A similar issue was present on the Spectrum Digital PCB (described in item 3).

    3. The two byte truncation happens only in our code not in the CSL_USB_PollExample project. Our application code is a little different than what application code is run in the CSL_USB_PollExample project. Nonetheless both projects suffer from corrupted USB transfers after the device sends an odd amount of data to the host. I have tried various length transfers from 2 bytes to 7 bytes when communicating between the host and device. In the CSL_USB_PollExample project run on Spectrum Digitals PCB, I have found it to demonstrate one of the following issues after the device sends the host an odd number of bytes:
    - Upon the next write and read cycle from the host, the read will generate an error stating there are no bytes to be read.
    - Upon the next write and read cycle from the host, the host application will generate a USB babble error message.
    - Upon the next write and read cycle from the host, the data received by the host will not be what was sent to the device and 1 byte is missing in the transfer.

    All the testing I performed with the host application from TI (sprabd7b) was in single block transfer mode.

    Please let me know if you need any additional information.

    Thank you,

    Ben
  • Hi Ben,

    Attached CSL file  "csl_usbAux.h" -  provides the fix for USB odd bytes bulk transfer issue that were seen with respect to USB CSL Poll mode example( CSL_USB_PollExample ). The issue looks resolved with limited testing that we had performed.

    Hope this fix resolves the issue with your code aswell.

    Regards

     Vasanth

    csl_usbAux.h

  • Hi Vasanth,

    Initial testing on our end seems to indicate the issue is resolved.

    We will keep working with it, but for now everything seems working!

    Thank you,

    Ben