<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/26454/how-to-enable-and-use-dma-for-usb-bulk-in-endpoints</link><description> 
Hi, 

 
I&amp;#39;m using uVision 4 with the MCB2300 development board. I&amp;#39;m
developing a software that periodically transmits data (status
information) from the device to the host (as first step, the data are
sent without being explicitly requested by the host</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/155790?ContentTypeID=1</link><pubDate>Mon, 10 Jan 2011 06:06:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:22c28204-d4ab-4e9f-8383-792f4521b92f</guid><dc:creator>Christoph Ciesla</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi,&lt;/p&gt;

&lt;p&gt;
I&amp;#39;m back from Christmas vacation and first want to thank you all
for your replies. And I have some good news: my example works now. My
solution was almost correct, the only problem was that the data
buffer the DMA descriptor points to was not located in USB RAM
(obviously this is required - thanks for the hint). I&amp;#39;ve moved it to
USB RAM (a higher region starting at 0x7fd01f00), and now my code
works as expected.&lt;br /&gt;
The next thing I&amp;#39;m going to do is to implement DMA for OUT
endpoints...&lt;/p&gt;

&lt;p&gt;
CC&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/155789?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2011 11:30:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8eca9aec-a608-41a4-a8fe-5799361db757</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;gt; is it possible to get the number of bytes which were
received by the last packet to determine if the packet was a normal
data packet or a command packet?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
The byte size of received transfer is written-back to the DD for
OUT EP.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;gt; Is it also possible to use USB_ReadEP() because I will
also use DMA for the BULK out endpoints?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
No. USB_ReadEP() is not available for the OUT EP, while DMA is
enabled on the EP.&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/155504?ContentTypeID=1</link><pubDate>Sat, 01 Jan 2011 11:28:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:227c8c0b-8455-4459-8cc0-443451c5fbbf</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;gt;&amp;gt; Raise a flag in SendDataToHost().&lt;br /&gt;
In USB_EndPoint2() callback, catch (event == USB_EVT_IN_DMA_NDR) and
drop the flag&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;gt; That means you will have to disable the usb interrupt,
setting up the flag together with the usb dma descriptor in the
SendDataToHost method. And easily drop the flag in the endpoint USB
ISR. IS it not possible to miss an important usb interrupt during the
settin up a new dma descriptor?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Keil&amp;#39;s USB_DMA_Setup() expects that the DD linked list is not
touched by the firmware while DMA is going on the target EP.
Therefore, while above flag raises, your firmware should not call
SendDataToHost() for new transfer.&lt;/p&gt;

&lt;p&gt;
If you want to run the linked list dynamically, you&amp;#39;ll need more
elaboration in the USB_DMA_Setup()&lt;br /&gt;
- Firstly, reserve a new DD on USB_RAM, populate it by the function
parameter (Next_DD_valid = false).&lt;br /&gt;
- If there is no DD on the linked list, assign the new DD as the top
of the linked list.&lt;br /&gt;
- Else, find the tail DD on the linked list of the EP&lt;br /&gt;
- - Fill Next_DD_pointer on the tail DD with the new DD&lt;br /&gt;
- - Raise Next_DD_valid on the tail DD&lt;br /&gt;
- checks EPxx_DMA_ENABLE bit for the target EP, by reading USBEpDMASt
register.&lt;br /&gt;
- If the bit drops, enable it by calling USB_DMA_Enable() routine.
For IN EP, start DMA manually, like above post.&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/155502?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2010 12:21:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b6734b2f-9f7e-41ad-8340-4e328a1563ee</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
is it possible to get the number of bytes which were received by
the last packet to determine if the packet was a normal data packet
or a command packet? Is it also possible to use USB_ReadEP() because
I will also use DMA for the BULK out endpoints?&lt;/p&gt;

&lt;pre&gt;
void EndpointISR()
{
        /* use of dma */
        if(event &amp;amp; USB_EVT_OUT_DMA_EOT)
        {       /* End of Transfer */
        if (USB_DMA_BufAdr(CDC_DEP_OUT) != ((unsigned int)DataBuf0 + DataIn0))
                {       /* Data Available */

                        /* determine if the rxd data is a cmd or a dmx data pkt */

/* is it possible to get the size of the rxd packet to determine if the packet is a data packet or a command packet?
*/
                         if(command_pkt)
                        {
                             USB_ReadEP(CDC_DEP_OUT, &amp;amp;CommandReq[0]);
                             SetupCommand(&amp;amp;CommandReq[0]);
                             return;
                        }

                }
        }
        if (event &amp;amp; (USB_EVT_OUT_DMA_EOT) | (USB_EVT_OUT_DMA_NDR))
        {       /* End of Transfer or New Descriptor Request */

                DD.BufAdr  = (unsigned int)DataBuf0 + DataIn0;
                   DD.BufLen  = DATA_TX_PKT_LEN;
                   DD.MaxSize = 64;              /* 64Byte for bulk-transfer */
                DD.Cfg.Val = 0;              /* Initial DMA Configuration */
                  USB_DMA_Setup (CDC_DEP_OUT, &amp;amp;DD);             /* Setup DMA */
                  USB_DMA_Enable(CDC_DEP_OUT);

        }


          /* 2) */
        if(event &amp;amp; USB_EVT_IN_DMA_NDR)
                dmaInProgress &amp;amp;= ~(1 &amp;lt;&amp;lt; EPAdr(CDC_DEP_IN));

}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/155152?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2010 11:11:29 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ce979c73-a6a8-412d-9ee2-6fd26e2d6f74</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&lt;br /&gt;
Raise a flag in SendDataToHost().&lt;br /&gt;
In USB_EndPoint2() callback, catch (event == USB_EVT_IN_DMA_NDR) and
drop the flag&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That means you will have to disable the usb interrupt, setting up
the flag together with the usb dma descriptor in the SendDataToHost
method. And easily drop the flag in the endpoint USB ISR. IS it not
possible to miss an important usb interrupt during the settin up a
new dma descriptor?&lt;/p&gt;

&lt;pre&gt;
void SendDataToHost()
{
   //set up dma descriptor

  //disable usb interrupts

  //if flag is set -&amp;gt; add Link = 1

  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);

  //enable usb interrupts again

 /* and these two lines must only be called if the flag was not set... right? */
  USB_DMA_Enable(CDC_DEP_IN);                  /* Enable DMA */
  LPC_USB-&amp;gt;USBDMARSet = 1 &amp;lt;&amp;lt; EPAdr(CDC_DEP_IN);

}
&lt;/pre&gt;

&lt;p&gt;
&lt;i&gt;&lt;br /&gt;
a) PC application sends a command (start / stop data streaming) over
serial TX&lt;br /&gt;
The device receives this command over the bulk OUT EP.&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;
Which command would that be - start transmitting/receiving?&lt;/p&gt;

&lt;p&gt;
::CreateFile() SetCommState ();&lt;br /&gt;
Readfile() or Writefile() - is there a call to the usb device?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/154725?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2010 10:52:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:309aa60d-7afb-4223-a954-1e0ef3c464cf</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;gt; do you know a suitable solution to determine the time when
the host is ready to receive the first byte of data?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
PC application should actively notify the timing to the
device.&lt;br /&gt;
As you are working on CDC,&lt;/p&gt;

&lt;p&gt;
a) PC application sends a command (start / stop data streaming)
over serial TX&lt;br /&gt;
The device receives this command over the bulk OUT EP.&lt;/p&gt;

&lt;p&gt;
b) PC application enables / disables DTR&lt;br /&gt;
The device receives Set_Control_Line_State request&lt;/p&gt;

&lt;p&gt;
Just after enumeration, usbser.sys (Windows CDC driver) drops DTR
by Set_Control_Line_State&lt;br /&gt;
CloseHandle() of the device handle also drops DTR by
Set_Control_Line_State&lt;br /&gt;
CreateFile() does nothing for DTR&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;gt; The LPC processor is able to receive or to transmit data but
both directions are not possilbe at the same time.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Endpoints run concurrently, time-shared in the split unit of
transaction.&lt;br /&gt;
Then, even whille your device sends long long data over the bulk IN
EP, the bulk OUT EP can receive commands from PC application. LPC
hardware also runs in this way, including DMA.&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/148627?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2010 09:51:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:969fa1f2-d401-4a13-ab91-100d2e05df30</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Tsuneo,&lt;/p&gt;

&lt;p&gt;
do you know a suitable solution to determine the time when the
host is ready to receive the first byte of data?&lt;/p&gt;

&lt;p&gt;
As well as, I&amp;#39;m searching for a good solution to switch between
receive / and transmit data. The LPC processor is able to receive or
to transmit data but both directions are not possilbe at the same
time. Is it a good point to add a additional HID interface with one
endpoint(in) so that I can change the direction?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/148569?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2010 07:53:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:75e343fb-fcb4-4a93-bdf8-956c99e15054</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
DMA Descriptors are managed in a linked list, for each
endpoint.&lt;br /&gt;
When USB_DMA_Setup() is called with &amp;quot;DD.Cfg.Type.Link = 1&amp;quot;, on the
same EP, new DD is chained after the last one.&lt;/p&gt;

&lt;pre&gt;
void SendDataToHost()
{
  USB_DMA_DESCRIPTOR DD;
  DD.BufAdr  = (unsigned int)pStartBufAddr;  /* DMA Buffer Address */
  DD.BufLen  = 256;                          /* DMA Packet-size */
  DD.MaxSize = 64;                           /* 64Byte for bulk-transfer */

  //DD.Cfg.Type.IsoEP = 0;
  //DD.Cfg.Type.ATLE = 0;
  DD.Cfg.Val = 0;                            /* Initial DMA Desc Configuration */
  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);           /* Register DD */


  /* ************* ZLP **********/

  DD.BufLen  = 0;             // Zero-Length
  DD.MaxSize = 64;
  DD.Cfg.Val = 0;             // Clear config parameters

  DD.Cfg.Type.Link = 1;       // link this DD after above first DD &amp;lt;-------- Add this line

  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);           /* Register DD */

  USB_DMA_Enable(CDC_DEP_IN);                  /* Enable DMA */
  LPC_USB-&amp;gt;USBDMARSet = 1 &amp;lt;&amp;lt; EPAdr(CDC_DEP_IN);
}
&lt;/pre&gt;

&lt;p&gt;
&lt;i&gt;&amp;gt; How can I determine if the dma is still in progress with
the last descriptor?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Raise a flag in SendDataToHost().&lt;br /&gt;
In USB_EndPoint2() callback, catch (event == USB_EVT_IN_DMA_NDR) and
drop the flag&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/148432?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2010 02:59:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:83cb981d-9542-4fab-a775-1f6af8f9e421</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;DD.Cfg.Type.Link = 1&amp;quot; must be, for chained DD.&lt;/p&gt;

&lt;p&gt;
If I will call the SendDataToHost() method immediately after the
last one, then I have to use Link = 1? How can I determine if the dma
is still in progress with the last descriptor?&lt;/p&gt;

&lt;pre&gt;
void test()
{
    SendDataToHost();   //tx 400bytes
    SendDataToHost();   //tx 400bytes
    SendDataToHost();   //tx 400bytes
}

/* timer isr will be called every 20ms */
void Timer0_ISR()
{
   test();
}
&lt;/pre&gt;

&lt;p&gt;
If I will do this, only 384-bytes will be transmitted instead of
400bytes. If set the &amp;quot;DD.Cfg.Type.Link = 0&amp;quot;.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/148175?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2010 02:04:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ccd51757-b51c-4962-860d-25dbbd2b6c9f</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
unfortunately it seems to be very complicated to use ZLPs....&lt;/p&gt;

&lt;pre&gt;
void SendDataToHost()
{
  USB_DMA_DESCRIPTOR DD;
  DD.BufAdr  = (unsigned int)pStartBufAddr;  /* DMA Buffer Address */
  DD.BufLen  = 256;                       /* DMA Packet-size */
  DD.MaxSize = 64;                        /* 64Byte for bulk-transfer */

  //DD.Cfg.Type.IsoEP = 0;
  //DD.Cfg.Type.ATLE = 0;
  DD.Cfg.Val = 0;                         /* Initial DMA Configuration */
  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);             /* Setup DMA */


  /* ************* ZLP **********/

  DD.BufLen  = 0;
  DD.MaxSize = 64;
  DD.Cfg.Val = 0;
  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);

  USB_DMA_Enable(CDC_DEP_IN);                  /* Enable DMA */
  LPC_USB-&amp;gt;USBDMARSet = 1 &amp;lt;&amp;lt; EPAdr(CDC_DEP_IN);
}
&lt;/pre&gt;

&lt;p&gt;
With this code my usb device will send only 0-byte packets to the
host; even if the host didn&amp;#39;t open the serial port....&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/147660?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 20:09:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a3e0d2be-6e52-4222-875d-4182cc21e54b</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
In the setup of the DD for ZLP, this line is wrong.&lt;/p&gt;

&lt;p&gt;
DD.MaxSize = 0; // &amp;lt;---- 64&lt;/p&gt;

&lt;p&gt;
For ZLP, make just DD.BufLen to zero. Leave DD.MaxSize as same as
wMaxPacketSize of the endpoint.&lt;br /&gt;
When DD.MaxSize is zero, it means No_Packet DD. The EP will be
NAKing.&lt;/p&gt;

&lt;p&gt;
&amp;quot;DD.Cfg.Type.Link = 1&amp;quot; must be, for chained DD.&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/146639?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 12:02:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:048b81df-3287-4c72-8e90-9dd37d429cf5</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
many thanks for your help!&lt;/p&gt;

&lt;p&gt;
Do you know how it would be possible to add a ZLP packet if I will
send 256bytes for example? With the above code, it doesn&amp;#39;t work
(unfortunately).&lt;/p&gt;

&lt;p&gt;
a) using &amp;quot;DD.Cfg.Type.Link = 1;&amp;quot; for the second dma descriptor
(ZLP)-&amp;gt; get two responses in the endpoint isr -&amp;gt; the status of
the dma in the endpoint ISR is always &amp;quot;DMA Idle - Waiting for
Trigger&amp;quot;&lt;/p&gt;

&lt;p&gt;
b) without &amp;quot;DD.Cfg.Type.Link = 1;&amp;quot; -&amp;gt; I will get two responses
with the dma status &amp;quot;DMA Transfer Done (no Errors)&amp;quot; - but I didn&amp;#39;t
receive anything on the host...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/145011?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 11:00:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bbe7df45-1dfc-4821-90ff-78a401a297d3</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;gt; The interrupt which occured after setting up the dma
descriptor in the SendDataToHost method, is a &amp;quot;New DD Request
Interrupt&amp;quot;... but after that nothing happens.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
As you don&amp;#39;t see USB_EVT_IN_DMA_EOT, something on the DD parameter
should be wrong.&lt;/p&gt;

&lt;p&gt;
DD.BufAdr = (unsigned int)DataBuf + DataIn; /* DMA Buffer Address
*/&lt;/p&gt;

&lt;p&gt;
Is DataBuf[] sits on USB RAM (8K bytes), starting from 0x7FD0 0000
?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;gt; Or is the solution better to start the first dma transfer
with the SendDataToHost function; and if another packet should be
transfered or not will be determined in the endpoint isr&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
In your first post, you said the firmware sends status info
periodically to host.&lt;br /&gt;
Then, the status info should be gathered in a timer ISR, or some
periodical routine.&lt;br /&gt;
SendDataToHost() is called from the same routine, too.&lt;br /&gt;
USB_EndPoint2() is not touched, at all.&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/145010?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 10:32:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:753a2496-f802-47bf-bd33-c204421094bb</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
voila it&amp;#39;s WORKING Tsuneo.... I kicked all the stuff out of the
endpoint isr and it works with 300Byte..&lt;/p&gt;

&lt;p&gt;
I made a small test example with 256 bytes so that I have to add a
ZLP - but it still fails....I can&amp;#39;t see anything with my software usb
sniffer...&lt;/p&gt;

&lt;pre&gt;
void SendDataToHost()
{
  USB_DMA_DESCRIPTOR DD;
  DD.BufAdr  = (unsigned int)pStartBufAddr;  /* DMA Buffer Address */
  DD.BufLen  = 256;                       /* DMA Packet-size */
  DD.MaxSize = 64;                        /* 64Byte for bulk-transfer */

  //DD.Cfg.Type.IsoEP = 0;
  //DD.Cfg.Type.ATLE = 0;
  DD.Cfg.Val = 0;                         /* Initial DMA Configuration */
  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);             /* Setup DMA */


  /* ************* ZLP **********/

  DD.BufLen  = 0;
  DD.MaxSize = 0;

  //DD.Cfg.Type.Link = 1;   ????
  DD.Cfg.Val = 0;
  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);

  USB_DMA_Enable(CDC_DEP_IN);                  /* Enable DMA */
  LPC_USB-&amp;gt;USBDMARSet = 1 &amp;lt;&amp;lt; EPAdr(CDC_DEP_IN);
}
&lt;/pre&gt;

&lt;p&gt;
My endpoint ISR is still empty. It seems that the ZLP is not yet
recognized.... What does the DD.Cfg.Type.Link stand for???&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/142796?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 09:37:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:578456e1-c667-486d-9446-77b8375a5c03</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Tsuneo,&lt;/p&gt;

&lt;p&gt;
thanks for your great response.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&lt;br /&gt;
USB_EndPoint2() should be called twice,&lt;br /&gt;
- one for USB_EVT_IN_DMA_EOT, when the first transfer (300 bytes)
finishes.&lt;br /&gt;
- another for USB_EVT_IN_DMA_NDR, when the USB engine finds no DD
chained after the first DD.&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That means I can set up each dma transfer with my method
SendDataToHost; and I didn&amp;#39;t have to setup anything in the endpoint
ISR. Because the packets which will be transmitted by the usb dma are
not a continuous stream. That means packets are not always available,
when the USB_EVT_IN_DMA_NDR event fires.&lt;/p&gt;

&lt;p&gt;
Or is the solution better to start the first dma transfer with the
SendDataToHost function; and if another packet should be transfered
or not will be determined in the endpoint isr&lt;/p&gt;

&lt;pre&gt;
void USB_EndPoint2 (unsigned int event)
{
  if (event &amp;amp; USB_EVT_IN_DMA_NDR)
  {     /* End of Transfer or New Descriptor Request */

        if(new_pkt_to_tx_is_avail == yes)
        {
              DD.BufAdr  = (unsigned int)DataBuf + DataIn;    /* DMA Buffer Address */
              DD.BufLen  = 300;                       /* DMA Packet-size */
              DD.MaxSize = 64;                     /* 64Byte for bulk-transfer */

              DD.Cfg.Val = 0;                   /* Initial DMA Configuration */
              USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);                                    /* Setup DMA */
             USB_DMA_Enable(CDC_DEP_IN);                                     /* Enable DMA */

             //! I didn&amp;#39;t need this command here, did I?
              LPC_USB-&amp;gt;USBDMARSet |= 0x20;

        }
        else
        {
            DD.BufAdr  = (unsigned int)DataBuf + DataIn;    /* DMA Buffer Address */
              DD.BufLen  = 0;                       /* DMA Packet-size */
              DD.MaxSize = 0;                     /* 64Byte for bulk-transfer */

              DD.Cfg.Val = 0;                   /* Initial DMA Configuration */
              USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);                                    /* Setup DMA */
             USB_DMA_Enable(CDC_DEP_IN);                                     /* Enable DMA */

             //! I didn&amp;#39;t need this command here, did I?
              LPC_USB-&amp;gt;USBDMARSet |= 0x20;


         }
   }
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/139784?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 09:02:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7dee2108-a336-4f2c-b0f5-3d82a4b79bfd</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;gt; After calling the method SendDataToHost(), the
endpoint(in) will be executed only once.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Do you mean USB_EndPoint2() is called just once ?&lt;br /&gt;
What is the &amp;quot;event&amp;quot; value on USB_EndPoint2() call?&lt;/p&gt;

&lt;p&gt;
USB_EndPoint2() should be called twice,&lt;br /&gt;
- one for USB_EVT_IN_DMA_EOT, when the first transfer (300 bytes)
finishes.&lt;br /&gt;
- another for USB_EVT_IN_DMA_NDR, when the USB engine finds no DD
chained after the first DD.&lt;/p&gt;

&lt;p&gt;
I said your code seems fine, but now I have doubt on this line in
USB_EndPoint2()&lt;/p&gt;

&lt;p&gt;
if (event &amp;amp; (USB_EVT_IN_DMA_EOT) | (USB_EVT_IN_DMA_NDR))&lt;/p&gt;

&lt;p&gt;
Respond to just USB_EVT_IN_DMA_NDR, ignore USB_EVT_IN_DMA_EOT.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;gt; is it enough to set up the dma in the SendDataToHost() metho
for each packet which has to be send to the host?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
DMA automatically split the transfer into DD.MaxSize (64 bytes),
when DD.BufLen is greater than DD.MaxSize.&lt;br /&gt;
When the entire transfer of DD.BufLen completes, USB_EndPoint2() is
called with USB_EVT_IN_DMA_EOT&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;gt; Or did I also specify the dma setup in the endpoint ISR
(as shown in the code above)?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
For single transfer, you don&amp;#39;t need to touch to DMA in the
endpoint ISR, at all.&lt;br /&gt;
I thought you want to send the transfer repeatedly for test :-)&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;gt; Or do I have to send a ZLP packet each time the endpoint
isr will be called (with packet-size zero)?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
For CDC bulk IN endpoint, ZLP is required just when the transfer
size is just the multiple of wMaxPacketSize (64 bytes).&lt;br /&gt;
ie. 64, 128, 192, 256, ...&lt;br /&gt;
As you send 300 bytes, no ZLP is required.&lt;/p&gt;

&lt;p&gt;
When ZLP is required, link another DMA Descriptor (DD) for ZLP
after the first DD&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/132074?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 08:54:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2f0a3c9e-dacc-4e57-ac2c-a06ae4eb754d</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
The interrupt which occured after setting up the dma descriptor in
the SendDataToHost method, is a &amp;quot;New DD Request Interrupt&amp;quot;... but
after that nothing happens.&lt;/p&gt;

&lt;pre&gt;
if (LPC_USB-&amp;gt;USBDMAIntSt &amp;amp; 0x00000002) {          /* New DD Request Interrupt */
{
}
&lt;/pre&gt;

&lt;p&gt;
I hope you could give me some hints to get in working...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/131850?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 08:10:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7d1971af-b2f6-4170-875d-595deb8d5f8b</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
here&amp;#39;s the whole code from the usb_reset() - I didn&amp;#39;t change
anyhting in this function...&lt;/p&gt;

&lt;pre&gt;
void USB_Reset (void) {
#if USB_DMA
  uint32_t n;
#endif

  LPC_USB-&amp;gt;USBEpInd = 0;
  LPC_USB-&amp;gt;USBMaxPSize = USB_MAX_PACKET0;
  LPC_USB-&amp;gt;USBEpInd = 1;
  LPC_USB-&amp;gt;USBMaxPSize = USB_MAX_PACKET0;
  while ((LPC_USB-&amp;gt;USBDevIntSt &amp;amp; EP_RLZED_INT) == 0);

  LPC_USB-&amp;gt;USBEpIntClr  = 0xFFFFFFFF;
  LPC_USB-&amp;gt;USBEpIntEn   = 0xFFFFFFFF ^ USB_DMA_EP;
  LPC_USB-&amp;gt;USBDevIntClr = 0xFFFFFFFF;
  LPC_USB-&amp;gt;USBDevIntEn  = DEV_STAT_INT    | EP_SLOW_INT    |
               (USB_SOF_EVENT   ? FRAME_INT : 0) |
               (USB_ERROR_EVENT ? ERR_INT   : 0);

#if USB_DMA
  LPC_USB-&amp;gt;USBUDCAH   = USB_RAM_ADR;
  LPC_USB-&amp;gt;USBDMARClr = 0xFFFFFFFF;
  LPC_USB-&amp;gt;USBEpDMADis  = 0xFFFFFFFF;
  LPC_USB-&amp;gt;USBEpDMAEn   = USB_DMA_EP;
  LPC_USB-&amp;gt;USBEoTIntClr = 0xFFFFFFFF;
  LPC_USB-&amp;gt;USBNDDRIntClr = 0xFFFFFFFF;
  LPC_USB-&amp;gt;USBSysErrIntClr = 0xFFFFFFFF;
  LPC_USB-&amp;gt;USBDMAIntEn  = 0x00000007;
  DDMemMap[0] = 0x00000000;
  DDMemMap[1] = 0x00000000;
  for (n = 0; n &amp;lt; USB_EP_NUM; n++) {
    udca[n] = 0;
    UDCA[n] = 0;
  }
#endif
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/130720?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 07:43:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cd9f328e-4809-4c43-87ec-2ed462d52abb</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
One further question: is it enough to set up the dma in the
SendDataToHost() metho for each packet which has to be send to the
host? Or did I also specify the dma setup in the endpoint ISR (as
shown in the code above)? Or do I have to send a ZLP packet each time
the endpoint isr will be called (with packet-size zero)?&lt;/p&gt;

&lt;p&gt;
I&amp;#39;ve not to deal with ZLP and so on - the dma will everything do
for me?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/126580?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 07:33:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:01861edf-9762-421d-9d9c-e0e828969af1</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Tsuneo,&lt;/p&gt;

&lt;p&gt;
yes I did the set up in the usbcfg.h file for the second
endpoint(in/out).&lt;/p&gt;

&lt;pre&gt;
#define USB_DMA_EP          0x00000030

LPC_USB-&amp;gt;USBEpDMAEn   = USB_DMA_EP;
&lt;/pre&gt;

&lt;p&gt;
Using LPC_USB-&amp;gt;USBDMARSet = 1 &amp;lt;&amp;lt; EPAdr(CDC_DEP_IN);
didn&amp;#39;t solve the problem. After calling the method SendDataToHost(),
the endpoint(in) will be executed only once.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/116169?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2010 07:16:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1562dad4-45c4-46cb-924c-f379cbb2eb0c</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
Your code seems fine.&lt;/p&gt;

&lt;p&gt;
Did you set up usbcfg.h for the DMA Endpoint (USB_DMA_EP) ?&lt;br /&gt;
USB_DMA_EP value is used to disable slave interrupt on the EP
(EP_INT_EN) in USB_Reset() (usbhw.c)&lt;br /&gt;
While slave interrupt is enabled on the EP (default), DMA doesn&amp;#39;t
fire.&lt;/p&gt;

&lt;p&gt;
Maybe, this line is fine&lt;br /&gt;
LPC_USB-&amp;gt;USBDMARSet |= 0x20;&lt;/p&gt;

&lt;p&gt;
But, in Keil style,&lt;br /&gt;
DMA_REQ_SET = 1 &amp;lt;&amp;lt; EPAdr(CDC_DEP_IN);&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/102367?ContentTypeID=1</link><pubDate>Tue, 28 Dec 2010 10:05:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:262184b3-5412-4193-a770-fd0752d5a6f1</guid><dc:creator>Ola Melzig</dc:creator><description>&lt;p&gt;&lt;p&gt;
same problem here. Tsuneo could you give me some further
steps???&lt;/p&gt;

&lt;p&gt;
I&amp;#39;v installed a separate function where I init a new dma packet
transfer, if a packet is there to tx.&lt;/p&gt;

&lt;pre&gt;
void SendDataToHost()
{
  USB_DMA_DESCRIPTOR DD;
  DD.BufAdr  = (unsigned int)DataBuf + DataIn;  /* DMA Buffer Address */
  DD.BufLen  = 300;                       /* DMA Packet-size */
  DD.MaxSize = 64;                        /* 64Byte for bulk-transfer */

  DD.Cfg.Val = 0;                         /* Initial DMA Configuration */
  USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);             /* Setup DMA */
  USB_DMA_Enable(CDC_DEP_IN);                  /* Enable DMA */

  LPC_USB-&amp;gt;USBDMARSet |= 0x20;
}
&lt;/pre&gt;

&lt;p&gt;
After that the host sends a pkt to the endpoint(CDC_DEP_IN).&lt;/p&gt;

&lt;pre&gt;
void USB_EndPoint2 (unsigned int event)
{
   if(event &amp;amp; USB_EVT_IN_DMA_EOT)
   {
       //??? what do I have to do here??
   }

  if (event &amp;amp; (USB_EVT_IN_DMA_EOT) | (USB_EVT_IN_DMA_NDR))
  {     /* End of Transfer or New Descriptor Request */

        DD.BufAdr  = (unsigned int)DataBuf + DataIn;    /* DMA Buffer Address */
        DD.BufLen  = 300;                       /* DMA Packet-size */
        DD.MaxSize = 64;                     /* 64Byte for bulk-transfer */

        DD.Cfg.Val = 0;                   /* Initial DMA Configuration */
        USB_DMA_Setup (CDC_DEP_IN, &amp;amp;DD);                                    /* Setup DMA */
        USB_DMA_Enable(CDC_DEP_IN);                                     /* Enable DMA */

        LPC_USB-&amp;gt;USBDMARSet |= 0x20;

   }
}
&lt;/pre&gt;

&lt;p&gt;
This method will be called only once. But no data will be
transfered to the host... :-(&lt;/p&gt;

&lt;p&gt;
Any help would be very appreciated!&lt;/p&gt;

&lt;p&gt;
Ola&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/90773?ContentTypeID=1</link><pubDate>Wed, 22 Dec 2010 07:19:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:02e84040-a149-4cbd-bbfd-1597559e9623</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
To start transfer on a new DD for an IN endpoint,&lt;br /&gt;
Enable DMA (USBEpDMAEn) and write to USBDMARSet register manually, to
arm the endpoint buffer with the DD.&lt;/p&gt;

&lt;p&gt;
It was once discussed on this thread of LPC2000&lt;br /&gt;
&lt;a href="http://tech.groups.yahoo.com/group/lpc2000/message/49934"&gt;tech.groups.yahoo.com/.../49934&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Tsuneo&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/90776?ContentTypeID=1</link><pubDate>Wed, 22 Dec 2010 04:12:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5482d038-f2d6-4df0-80e9-47a8ac67260d</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ask Keil support - they have ready code samples, also for that as
far as I can recall.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable and use DMA for USB bulk IN endpoints</title><link>https://community.arm.com/thread/59003?ContentTypeID=1</link><pubDate>Wed, 22 Dec 2010 03:54:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:41e6eb1b-fd2d-4910-a9a3-b6ee8249eb9b</guid><dc:creator>Christoph Ciesla</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi,&lt;/p&gt;

&lt;p&gt;
sorry, I forgot to mention that I&amp;#39;m using a LPC2378.&lt;/p&gt;

&lt;p&gt;
CC&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>