<?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>usb bulk driver</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/39475/usb-bulk-driver</link><description> 
Hi all, 
I am using LPC2148 microcontroller. Bulk driver for usb2.0 full speed
is written. Currently only 64 bytes of data is written to the
endpoint. So the speed achieved is less. I have read in the books
that maximum 19 packets of 64 byte length</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: usb bulk driver</title><link>https://community.arm.com/thread/147747?ContentTypeID=1</link><pubDate>Wed, 30 Nov 2011 04:00:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5102b7f3-1fdf-4200-acd1-49d848119f39</guid><dc:creator>Shahida Asharf</dc:creator><description>&lt;p&gt;&lt;p&gt;
How often the host sends IN token to the device in the case of
bulk transfer. In interrupt transfer it will be the interval
mentioned in the endpoint descriptor. But for bulk its not clear for
me. can u help me in this regards.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: usb bulk driver</title><link>https://community.arm.com/thread/146783?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2011 21:20:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b5384fc7-be2f-4d95-82f6-9c66cf41f805</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
To evaluate firmware performance, I observe device response on a
hardware bus analyzer. When any IN-NAK or OUT-DATA-NAK transaction
appears in large data transfer, tuning on the bulk endpoint routine
may improve the performance.&lt;/p&gt;

&lt;p&gt;
Recent quad-core PCs can drive the bus with 19 full-size packets
per frame. But on dual-core generation, 18 packets, at most.&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: usb bulk driver</title><link>https://community.arm.com/thread/145221?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2011 03:21:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a4a8af6d-81f1-49c4-a7a4-8ba13f4a0747</guid><dc:creator>Shahida Asharf</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hello Tsuneo&lt;br /&gt;
Can u suggest me some tool to check the USB throughput.?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: usb bulk driver</title><link>https://community.arm.com/thread/143049?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2011 23:55:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ce3d7cef-53aa-4a84-a0a2-6019d7b9b07e</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;gt; We could achieve a speed of 720kbytes/s.&lt;/p&gt;

&lt;p&gt;
Not enough.&lt;br /&gt;
You may saturates the bus, if no other device hooks on the bus.&lt;br /&gt;
19 full-size packets/frame = 1,216,000 bytes/s&lt;/p&gt;

&lt;p&gt;
a) How many bytes do you request for read/write call on the host
side?&lt;br /&gt;
In both directions, transfer speed is proportional to the size of
single read/write call, until bus bandwidth saturates. Test it at
least a couple of 10KBytes. Even MegaBytes will do.&lt;/p&gt;

&lt;p&gt;
b) On the device side, did you implement double buffer scheme on
my first post?&lt;/p&gt;

&lt;p&gt;
&amp;gt; Thesycon&lt;/p&gt;

&lt;p&gt;
Surely, Thesycon supplies easy DLL for their driver.&lt;br /&gt;
But, isn&amp;#39;t WinUSB enough?&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: usb bulk driver</title><link>https://community.arm.com/thread/140096?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2011 21:48:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d7a20450-c0aa-4f2e-a30f-5a77ad898f88</guid><dc:creator>Shahida Asharf</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Tsueno,&lt;br /&gt;
Now the problem is solved. We where using jungo driver in the host
side. With that speed of 32kbytes/s was only achieved.We evaluated
the same firmware in the device side with Thesycon host driver. We
could achieve a speed of 720kbytes/s.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: usb bulk driver</title><link>https://community.arm.com/thread/136653?ContentTypeID=1</link><pubDate>Thu, 10 Nov 2011 19:58:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:332fb613-9aad-4a43-a8cc-5c5f8fbee492</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
USBDevIntSt.TxENDPKT is available while the packet is passed to
USBTxData register, after USBTxPLen register is set. I&amp;#39;m not sure
this bit is still available after SelectEndpoint / Validate commands
are issued. Even if this bit would be available, it could be nothing
after Validate command.&lt;/p&gt;

&lt;p&gt;
Rewrite your code as I suggested.&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: usb bulk driver</title><link>https://community.arm.com/thread/127201?ContentTypeID=1</link><pubDate>Thu, 10 Nov 2011 02:40:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6f870435-d3a8-48bb-b103-2793f750e218</guid><dc:creator>Shahida Asharf</dc:creator><description>&lt;p&gt;&lt;p&gt;
USBDevIntSt register bit &amp;quot;TxENDPKT&amp;quot; will be set if The number of
data bytes transferred to the FIFO equals the number of bytes
programmed in the TxPacket length register.That was what i was
checking.&lt;br /&gt;
Is it a proper way to send multiple packets in a single frame of
1ms?&lt;br /&gt;
Or else &lt;b&gt;please suggest me the procedure to sent multiple packets
in a frame in bulk transfer so that i can utilize full
bandwidth?&lt;/b&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: usb bulk driver</title><link>https://community.arm.com/thread/119536?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2011 14:15:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:41a13d6f-9ff9-4899-ba0a-e8653f4da430</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ah, I remember.&lt;br /&gt;
USBDevIntSt is read-only. To clear USBDevIntSt, write to
USBDevIntClr.&lt;br /&gt;
Troublesome SIE :-)&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: usb bulk driver</title><link>https://community.arm.com/thread/105455?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2011 13:32:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b7f93210-f50c-4ac8-b771-f6ffe86dbc85</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;gt; I could find that the first 64 bytes of data over written
by last 64 bytes.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
In this line, you are waiting for the end of Validate command,
before writing next packet.&lt;/p&gt;

&lt;p&gt;
while ((USBDevIntSt &amp;amp; C_TxEndPktInt_U32X) == C_Zero_U8X);&lt;/p&gt;

&lt;p&gt;
What is the value of C_TxEndPktInt_U32X and C_Zero_U8X?&lt;br /&gt;
Are they CCEMPTY bit (0x10) and 0?&lt;/p&gt;

&lt;p&gt;
Clear CCEMPTY bit before putting Validate command.&lt;/p&gt;

&lt;p&gt;
Otherwise, this bit is kept in 1 by the Select Endpoint command,
just before the Validate command. And then, your while loop will be
passed through immediately.&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: usb bulk driver</title><link>https://community.arm.com/thread/79733?ContentTypeID=1</link><pubDate>Tue, 08 Nov 2011 21:55:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:db017e25-d844-4106-bb89-b50027ca2dc2</guid><dc:creator>Shahida Asharf</dc:creator><description>&lt;p&gt;&lt;p&gt;
My present code for writing to the endpoint is as follows. This is
called in the ISR routine&lt;br /&gt;
Maximum packet size is 64. So v_Count_u32r = 64&lt;/p&gt;

&lt;pre&gt;
static U32 USB_WriteEP (U32 EPNum, U8 *P_PointerToData_U8R, U32 v_Count_u32r)
{
        U32 v_Temp_u32r;
        U32 v_NumberOfPacks_u32r = ((v_Count_u32r + 3) &amp;gt;&amp;gt;2);

        USBCtrl = ((EPNum &amp;amp; 0x0F) &amp;lt;&amp;lt; 2) | C_USBCntrlWREnbl_U32X;
        USBTxPLen = v_Count_u32r;
        for (v_Temp_u32r = 0; v_Temp_u32r &amp;lt; v_NumberOfPacks_u32r; v_Temp_u32r++)
        {
        USBTxData = *((__packed U32 *)P_PointerToData_U8R);
        P_PointerToData_U8R += 4;
        }
        USBCtrl = 0;
        USB_WriteCmnd(Z_CmndSelEP(USB_EPAddr(EPNum)));
        USB_WriteCmnd(C_CmndValidBuff_U32X);
        return (v_Count_u32r);
}
&lt;/pre&gt;

&lt;p&gt;
Only 64 bytes is transmitted in one interrupt cycle. Suppose i
need to sent 128 bytes i read in the LPC2148 data sheet that
&amp;lt;bold&amp;gt;then the software&lt;br /&gt;
submits 64 bytes packet twice&amp;lt;/bold&amp;gt;.&lt;br /&gt;
I modified my code as follows. Values are hard coded and only for
testing purpose.&lt;/p&gt;

&lt;pre&gt;
static U32 USB_WriteEP (U32 EPNum, U8 *P_PointerToData_U8R, U32 v_Count_u32r)
{
        U32 v_Temp_u32r,i;

        U32 v_NumberOfPacks_u32r;



        if(v_Count_u32r &amp;gt; 64)
        {

        for(i=0;i&amp;lt;2;i++)
        {
        USBCtrl = ((EPNum &amp;amp; 0x0F) &amp;lt;&amp;lt; 2) | C_USBCntrlWREnbl_U32X;
        v_NumberOfPacks_u32r = ((64 + 3) &amp;gt;&amp;gt;2);
        USBTxPLen = 64;
        for (v_Temp_u32r = 0; v_Temp_u32r &amp;lt; v_NumberOfPacks_u32r; v_Temp_u32r++)
        {
        USBTxData = *((__packed U32 *)P_PointerToData_U8R);
        P_PointerToData_U8R += 4;
        }

    USBCtrl = 0;
        USB_WriteCmnd(Z_CmndSelEP(USB_EPAddr(EPNum)));
    USB_WriteCmnd(C_CmndValidBuff_U32X);
        while ((USBDevIntSt &amp;amp; C_TxEndPktInt_U32X) == C_Zero_U8X);


        }


        }
        else
        {
        USBCtrl = ((EPNum &amp;amp; 0x0F) &amp;lt;&amp;lt; 2) | C_USBCntrlWREnbl_U32X;
        v_NumberOfPacks_u32r = ((v_Count_u32r + 3) &amp;gt;&amp;gt;2);
        USBTxPLen = v_Count_u32r;
        for (v_Temp_u32r = 0; v_Temp_u32r &amp;lt; v_NumberOfPacks_u32r; v_Temp_u32r++)
        {
        USBTxData = *((__packed U32 *)P_PointerToData_U8R);
        P_PointerToData_U8R += 4;
        }


        }
                USBCtrl = 0;
        USB_WriteCmnd(Z_CmndSelEP(USB_EPAddr(EPNum)));
        USB_WriteCmnd(C_CmndValidBuff_U32X);

        return (v_Count_u32r);
}
&lt;/pre&gt;

&lt;p&gt;
I could find that the first 64 bytes of data over written by last
64 bytes. If the EP buffer size is sufficient i dont think this will
happen. I could write only maximum packet size to USBTxPLen.I have
read that 19 packet of 64 byte length can be transmitted. Can u
suggest me some improvement in this regards to write more data?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: usb bulk driver</title><link>https://community.arm.com/thread/60043?ContentTypeID=1</link><pubDate>Tue, 08 Nov 2011 07:36:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:097266fb-f4c4-4285-a73a-8bd0cfad689d</guid><dc:creator>Chinzei Tsuneo</dc:creator><description>&lt;p&gt;&lt;p&gt;
When you have large data on a buffer, more than 64 bytes, you may
see greater transfer speed.&lt;/p&gt;

&lt;p&gt;
The firmware declares these global variables,&lt;br /&gt;
- a transfer buffer&lt;br /&gt;
- data size on the buffer&lt;br /&gt;
- index on the buffer&lt;br /&gt;
- a occupied flag&lt;/p&gt;

&lt;p&gt;
data size, index and flag are initialized in Set_Configuration
request handler&lt;/p&gt;

&lt;p&gt;
In the ISR of the bulk IN EP,&lt;br /&gt;
1) If occupied flag drops, return&lt;br /&gt;
2) Call Select Endpoint command of the protocol engine, and get F/E
bit of the bulk IN EP&lt;br /&gt;
3) If F/E bit is 0 (next buffer is empty), - pass next packet from
the index on the buffer to the IN endpoint - The packet size is the
smaller one, data size or 64 bytes else return&lt;br /&gt;
4) Increase index by this packet size, decrease data size by this
packet size&lt;br /&gt;
5) If data size is 0, drop occupied flag and return else back to
2)&lt;/p&gt;

&lt;p&gt;
Outside of the ISR, firmware starts transfer, when occupied flag
drops.&lt;br /&gt;
1) Fill data to the buffer, set data size&lt;br /&gt;
2) Clear the index and raise the occupied flag&lt;br /&gt;
3) Force bulk EP interrupt by USBEpIntSet register&lt;/p&gt;

&lt;p&gt;
In this way, your firmware uses the double buffer effectively, and
gets top speed.&lt;/p&gt;

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