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.

TM4C123 USB Bulk Device Example WITHOUT Buffers

Other Parts Discussed in Thread: EK-TM4C123GXL

I need to test bulk writes of specific size packets (64 Bytes) using the USBDBulkPacketWrite function. I cannot find a working example of how to do this WITHOUT using buffers! Any help would be appreciated.

  • Hello Mark,

    The bulk example has been built with the Ring Buffers as it makes data management easier. May I ask why you want to do without buffers?

    Regards
    Amit
  • There are two reasons:
    1) The USB Library Guide discusses using bulk example without buffers but does not show the full code for an example. This is a fundamental part of learning USB and SHOULD be included in the example projects. Ti providing partial document examples is not helpful and frustrating to new users.
    2) I have a fixed format packet and using buffers causes problems with reading whole packets. Also, I want to start with the fundamentals and work my way up to more complex examples.

    Does TI have an example or can you send me somewhere to look?
  • Hello Mark,

    For the USB Bulk class device, we do not have an example. The example for bulk class device is with Buffers. The documentation shows that both buffer use and no use are available, but provides an example for the former.

    I can help build an example if you take the lead without buffers.

    Regards
    Amit
  • Amit,

    Here is some code I found in the forums (Forum Heading: LM3S9B90 USB Trouble) for a simple performance test without buffers:

    tUSBDBulkDevice *myDevice;

    const tUSBDBulkDevice g_sBulkDevice =
    {
    USB_VID_LUMINARY,
    USB_PID_BULK,
    500,
    USB_CONF_ATTR_SELF_PWR,
    RxHandler,
    (void *)&g_sBulkDevice,
    TxHandler,
    (void *)&g_sBulkDevice,
    g_pStringDescriptors,
    NUM_STRING_DESCRIPTORS,
    &g_sBulkInstance
    };

    ...
    myDevice=USBDBulkInit(0, &g_sBulkDevice);
    ...
    while(1)
    {
    transmitAvail=USBDBulkTxPacketAvailable(myDevice);
    if(transmitAvail>transmissionLength)
    {
    transmitReturn = USBDBulkPacketWrite(myDevice, &(data[0]), transmissionLength, 0);
    }
    }

    When I run nothing comes out on the usb wire?
    1) Is the g_sBulkDevice structure correct?
    2) Is the USBDBulkTxPacketAvailable a reliable way to sequence the USBDBulkPacketWrite(myDevice? When I run the TxHandler never fires.
  • Hello Mark

    Unfortunately, with a lot of "...", I cannot compile the code. Also there was a change TivaWare 2.1.1 for usblib which requires some code migration to be done from StellarisWare.

    1. Does the device enumerate on the Host?
    2. Please share the CCS project instead of the code snippet.

    Regards
    Amit
  • How do I get the project to you?
  • To answer question 1 - Yes the Host Application sees the Bulk USB Device.

    The project is a modified usb_dev_bulk example with NO buffers
  • Hello Mark.

    Click on "Use rich formatting" on bottom left when replying to the post. It will navigate you to the full editor, where you can attach a the CCS project in zip.

    Regards
    Amit
  • I forgot to add I am using a EK-TM4C123GXL Launchpad
  • Hello Mark,

    Attached is the code which is now working (partially with the USB Bulk Example on Host PC). Note that since Buffer Management is now being done in application, after sending the few bytes the Application does not send anything to the Host.

    Now I believe, you have to do Buffer management in the application, which earlier the Ring Buffer was handling for the application.

    5123.usb_dev_bulk.zip

    Regards

    Amit

  • Amit,

    Thanks for the updated code. I do not see many changes. I cannot get the return project to build.

    Can you try to change the following:

    transmitReturn = USBDBulkPacketWrite(pDevice, &(data[0]), 64, true);

    to

    transmitReturn = USBDBulkPacketWrite(pDevice, &(data[0]), 64, false);

    to see if this eliminates the need for buffer management? I do not know what buffer management is!

    I read the manual and it states the following:

    If false, no further call will be made and the driver should schedule transmission of a short packet.
  • Hello Mark,

    The issue is that the use of false requires Ring Buffer management (see in the comments for USBDBulkPacketWrite).

    Also what is the error that you are getting in the return project. Since all the changes are in the main file, you can simply copy the main file content to your existing project.

    Regards
    Amit
  • Amit,

    Thanks for spending the time to work on this.

    I copied the main contents to do testing.

    I understand the false / true condition now.

    I really wish TI would have had an example with no buffers to start from.
  • Hello Mark,

    The USB Bulk Example on the host PC is not structured to be an independent application. There have been occasions in the past where forum members have requested for USB examples, but without a well defined application requirement the effort spent may be too high and then come the combinations of the code usage

    Regards
    Amit