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.

Tiva USB controller using dedicated DMA.

Other Parts Discussed in Thread: TM4C129XNCZAD

Hi, 

Are there any resources/examples available for using the DMA controller in device mode of TM4C129XNCZAD used in the DK-TM4C129X? I will need to transfer big chunks of data (video) through USB bulk transfer and was hoping to use DMA for that purpose. I should mention that the data is already in memory and needs to be transferred out via the the integrated DMA of the USB controller. 

  • So, I've tried to modify the existing bulk_dev example and have done the following to configure the integrated DMA:

    USBDBulkInit(0, &g_sBulkDevice);     // I havent touched this part. I added the following based on the document:

    // I have noticed that the DMA is getting initialized by calling

    //SBDCDInit(ui32Index, &psBulkDevice->sPrivateData.sDevInfo,(void *)psBulkDevice);

    // in bulkInit()

    if(USBDMANumChannels(0)){

    USBEndpointDMAEnable(USB0_BASE, USB_EP_1, USB_EP_DEV_IN);

      USBEndpointDMAConfigSet(USB0_BASE, USB_EP_1, (USB_EP_DEV_IN |USB_EP_DMA_MODE_1    |USB_EP_AUTO_SET));


      USBDMAChannelConfigSet(USB0_BASE,0,USB_EP_1,    (USB_DMA_CFG_BURST_NONE|USB_EP_DMA_MODE_1|USB_DMA_CFG_DIR_TX
      |USB_DMA_CFG_INT_EN /*|USB_DMA_CFG_EN*/)); // assign ch0 to ep1 dma mode 1-16 word bursts

    }


    and when I get a msg of "123" I used to have the following, after putting all the bytes in a buffer and then call:

    USBBufferDataWritten(&g_sTxBuffer, ui32Count); 


    now I have replaced it with: ( the transfer buffer is super big but its a multiplication of 64)

    USBDMAChannelAddressSet(USB0_BASE, 0,(void * )&g_pui8USBTxBuffer);
    USBDMAChannelCountSet(USB0_BASE, 0, 2048);
    USBEndpointPacketCountSet(USB0_BASE, 0, 2048/64);
    USBDMAChannelEnable(USB0_BASE,0);


    That's the the part i get stuck, I thought it could be as simple as this. though I believe I need to call bulkwrite some how, which is called through the USBBufferDataWritten(). So the question is what is the best way to do this, do i need to write a function to do that or there is already a function that takes care of this.

    Thanks in advance for your replies.

  • I have noticed there is an inconsistency between the function's arguments of the driver lib document and the actual library in : USBDMAChannelCountSet and USBEndpointPacketCountSet so i modified the above code to the follwing but still no luck!

    USBDMAChannelAddressSet(USB0_BASE, 1,&g_pui8USBTxBuffer);
    USBDMAChannelCountSet(USB0_BASE,5640,1);
    USBEndpointPacketCountSet(USB0_BASE, USB_EP_1, 2048/64);
    USBDMAChannelEnable(USB0_BASE,1);


    Moreover, based on pg. 1842 of the datasheet, section 25.3.6.4

    3. The BRSTM field should be configured in the USB DMA Control n (USBDMACTLn) register
    and the remaining bits should be programmed with the following: ENABLE = 0x1; DIR= 0x1;
    MODE= 0x1; IE=0x1.

    However, the Enable bit of register USBDMACTL1 doesn't get set!

    Any suggestions?? anyone?

  • Hi Mil,

    I'm looking into this and will get back to you when i have a concrete answer.

    Regards,


    -Austin

  • Are you modifying the usbdbulk.c to support DMA?

    If so have you checked out the usbdaudio.c, because it does provide an example of using DMA with endpoints similar to what you will need to do DMA with the bulk class. 

  • Hi Paul, 

    Please correct me if I'm wrong, but there is no Audio example provided for TM4C129X series in Tivaware and I didn't check to see if it uses DMA (Doesnt it use Isochronous transfer though?) i. However, I have looked into the dev_msc example that uses DMA. It looks very complicated and probably very very hard to modify it. Does this mean that I need to make changes to the dev_bulk example library ( such as changing the instance to include the DMA instance. Also, in that dev_msc example, the endpoint handler is much different than the bulk_transfer which uses the buffers. I should mention that I only need to use the DMA on my EP_IN. I was hoping that I could achieve this by some application level changes rather than modifying the library. Are there any alternatives?

    Thanks

  • Sorry, I was referring to the USB library example and making the changes at the application level would be tricky. The changes should really be made to the USB library in usblib/device/usbdbulk.c.  Also, you are correct that there is no USB audio example, but there is one in an upcoming release.  Unfortunately the new release does not add DMA to the USB Bulk device class.  It is a little tricky but the USB MSC has more complexities than a bulk class would since it must manage both commands and data on the same endpoints.  I would say that the example in usblib/device/usbdaudio.c is closer to the changes that would be necessary to add support to the USB bulk class.  

  • Thanks for the help, I was able to modify the usbdbulk.c and usbdbulk.h based on the usbdaudio.c and usbdmsc.c and finally got the DMA to work. 

  • Could you post your changes to usbdbulk.c? I'm also interested in adding DMA to the usb bulk driver.

  • Hello,

    I would be interested in your USB DMA implementation, currently I am working on the same issue ... bulk USB with DMA

    Could you post it to somewhere?

    Thank you

    Akos