Jump to content
43oh

Tiva TM4C-129X (DK), integrated USB DMA controller


Recommended Posts

Hey guys, 

So, I've been struggling with the integrated DMA in USB controller of the TM4C 129X development kit that uses TM4C129XNCZAD uC. I need to transfer video data from a a camera to another peripheral via USB. The data transfer from the camera to the uC is done through EPI and uDMA. Now I need to transfer the captured data from memory into USB controller via the integrated DMA. 

 

I have used the dev_bulk_transfer example and succeeded in transfering the data, however the example doesnt use DMA. The only example that uses DMA is the dev_msc example. Though, It is really hard to change my code based on that example. 

 

I have read and followed the driver library document and in section 34.3 of the SW-TM4C_DRL UG and got to this point:

 

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);

 

However the above doesnt work at all. I have also went through the msc class library and I know even though it uses the bulk transfer but the endpoint handler is different from what is in the dev_bulk example.

 

So, the question is do I need to make changes to the library of the dev_bulk (which I have already done so, but it is getting really complicated as it uses the USB buffer and ring buffer and etc. ) or it is just as simple as calling a few functions.

 

I have issued the questions on the TI's forum but there has been no response after 7 days. I'm really desperate in knowing how I should go about solving this issue as Im getting close to my deadline. Any help/suggestions will be welcome and greatly appreciated.

 

Thanks

-Milad

 

Link to post
Share on other sites

I'd be pretty impressed if anyone here has dealt with the Tiva that deeply, much less the new TM4C129 series :D

 

That said, maybe another pair of eyes can help.

 

What release of TivaWare is this that you're using?  I'm looking at the TivaWare USB driver documentation and it seems to refer to those USBDMA functions as USBLibDMA<blahblahblah>() so I can't even find proper documentation for the functions you're referring to.

 

The SW-TM4C_DRL UG, is that the Peripheral Driver Library guide?  I can't find a section 34 in there either... although I am going by the TI website for that part.  I'll see if I can d/l TivaWare to look further.  Maybe those documents are in the TivaWare d/l.

 

edit: Ah yes, apparently the TivaWare d/l has much more up-to-date documentation than the TI website.  Go figure.

Link to post
Share on other sites

Sadly, it looks like it's difficult to corroborate what the driverlib is doing here because for the TM4C129XNCZAD datasheet, the USB chapter is summarized and the full register description is only available under NDA.  It might be worth pursuing that route to get the full USB chapter so you can cross-check what the driverlib is doing and see if maybe there's an API call you're missing.

 

edit: Nevermind, you can download the NDA version of the datasheet directly, you just have to do the digital signature stuff to get it just like you do when you d/l TivaWare.  Go here and click the link inside the PDF: http://www.ti.com/lit/ml/spms421a/spms421a.pdf

Link to post
Share on other sites

Milad,

 

You haven't mentioned what is the USB Class and possibly Sub-Class of the device you are communicating with. This is essential to know as Tivaware only comes with certain drivers for certain devices, if they don't have one for your device, you will need to write it yourself, otherwise it will not successfully enumerate the device with the Tivaware USB Host or Device stack. Also, you have not really mentioned if your device is acting as a Host or Device in the communication.

 

The different USB Classes and Sub-Classes is listed here - http://www.usb.org/developers/defined_class

 

As you did mention that you got the dev_bulk_transfer example working, I am going to assume you have a Vendor Specific Class device that is acting as a Host. Unfortunately the Vendor Specific Class is one that does not explain much about the device you are communicating with, it is kind of a catch all, and often means it could be one of any of the other device classes, for example a CDC Class device, may often be identified as a Vendor Specific Class device. To move forward you need to have a clear understanding of the type of device you have and how its Interfaces and Endpoints are setup.  You can use a software package like USBlyzer to find this out - http://www.usblyzer.com/

 

Regarding Endpoints, you need to see what types you have available. The Bulk example will as the name suggestion require a Bulk Endpoint, however the code you are using from the DMA example may actually be setup to use an Isochronous Endpoint.

 

Basically, what I am saying is that you need to fully understand what type of USB device you are working with, what Class it is, how its Interfaces are setup and what Endpoints are on each Interface. Till you have a full understanding of all of this, you will be fumbling in the dark and very unlikely to enumerate with the device correctly, and if you do not enumerate correctly, you have no chance of working with the device.

 

A really good primer on a lot of what I have mentioned above is available here - http://www.beyondlogic.org/usbnutshell/usb1.shtml

 

Glenn.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...