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.

TM4C129XKCZAD: USBHCDPipeWrite() broken for large writes without DMA

Part Number: TM4C129XKCZAD

I'm going to go ahead and post this because TI is no longer maintaining the USB library or fixing bugs in it,   It took me a while to figure out exactly how to fix the bug.     There were hints, but no actual fix.

USBHCDPipeWrite()  is broken if you write more than 64 bytes at a time.    The root cause is a bug in the library code.

This is the TI code as shipped.

      if(bUseDMA == false)
        {
            //
            // Only send 64 bytes at a time if not using DMA.
            //
            if(ui32ByteToSend > 64)
            {
                ui32ByteToSend = 64;
            }
            else
            {
                //
                // Send the requested number of bytes.
                //
                ui32ByteToSend = ui32RemainingBytes;
            }

Heres the fix:

       if(bUseDMA == false)
        {
            //
            // Only send 64 bytes at a time if not using DMA.
            //
            if(ui32RemainingBytes > 64)
            {
                ui32ByteToSend = 64;
            }
            else
            {
                //
                // Send the requested number of bytes.
                //
                ui32ByteToSend = ui32RemainingBytes;
            }

I've tested this code an confirmed that it works.

  • Hello R Sexton,

    This is a known TivaWare bug which has been logged, and it's been brought up on the forums a few times. I did not bring this up as in your initial posting, you did not explicitly indicate that you were transferring larger than 64 bytes though reading carefully now I do recognize the comment about larger than 32 bytes. I had honestly thought of this fix right from the get go but got focused about the comment "What I'm seeing is that short writes (32 bytes) never send data onto the bus. " and didn't think that the greater than 64 byte fix was relevant. Sorry for not pursing that train of thought with you further at the time.

  • Is there a list of these known bugs? Every time I trip over one it wastes a lot of my engineering time. I have deliverables with schedules. I can't afford to waste time debugging other peoples code.
  • Hello R Sexton,

    We don't have such a list published, it's not typical for TI to do that with any of our libraries. That said I will see if there are any others related to USB you may benefit from knowing before running into them. Though unless you prefer to prioritize it, I will seek to provide such info after delving into your other 2 open USB issues tomorrow.