<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックUSB_EVT_OUT and Buffer Size</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554491#M14769</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by etunnel on Fri Sep 19 00:48:55 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I am learning about writing USB bulk transfer.&amp;nbsp; I noticed something that I don't understand.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On LPC4370 (the device), I setup a 4KB transfer buffer.&amp;nbsp; I found in debugger that I have to issue 1KB transfer 4 times on the PC host (running in Windows 7 using WINUSB API) before the EP OUT event handler is called with USB_EVT_OUT on the device.&amp;nbsp; Each time when 1KB transfer is issued, the host function call returns successful.&amp;nbsp; When I change the transfer size to be an odd size, for example 1000 bytes.&amp;nbsp; Immediately, EP OUT event handler is called with USB_EVT_OUT.&amp;nbsp; Is this an expected behavior?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a flag I can modify the behavior such that the event handler is called for each 1KB transfer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should I design a data flow protocol to send a small packet containing the length of transfer from host first?&amp;nbsp; Then, setup the transfer size in exact size on the LPC43xx device, subject to the max dma buffer allowed.&amp;nbsp; Finally, initiate the data transfer from the host.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 18:37:24 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T18:37:24Z</dc:date>
    <item>
      <title>USB_EVT_OUT and Buffer Size</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554491#M14769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by etunnel on Fri Sep 19 00:48:55 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I am learning about writing USB bulk transfer.&amp;nbsp; I noticed something that I don't understand.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On LPC4370 (the device), I setup a 4KB transfer buffer.&amp;nbsp; I found in debugger that I have to issue 1KB transfer 4 times on the PC host (running in Windows 7 using WINUSB API) before the EP OUT event handler is called with USB_EVT_OUT on the device.&amp;nbsp; Each time when 1KB transfer is issued, the host function call returns successful.&amp;nbsp; When I change the transfer size to be an odd size, for example 1000 bytes.&amp;nbsp; Immediately, EP OUT event handler is called with USB_EVT_OUT.&amp;nbsp; Is this an expected behavior?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a flag I can modify the behavior such that the event handler is called for each 1KB transfer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should I design a data flow protocol to send a small packet containing the length of transfer from host first?&amp;nbsp; Then, setup the transfer size in exact size on the LPC43xx device, subject to the max dma buffer allowed.&amp;nbsp; Finally, initiate the data transfer from the host.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:37:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554491#M14769</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: USB_EVT_OUT and Buffer Size</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554492#M14770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by etunnel on Fri Sep 19 00:54:32 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I missed one important piece of information:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the custom class with bulk transfer endpoint.&amp;nbsp; I experimented two examples provided in LPCOpen:&amp;nbsp;&amp;nbsp; usbd_rom_libusb and usbd_rom_bwtest.&amp;nbsp; Both examples using different sets of APIs exhibit the same behavior.&amp;nbsp; I am developing using LPCXpresso.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:37:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554492#M14770</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: USB_EVT_OUT and Buffer Size</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554493#M14771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mch0 on Fri Sep 19 04:26:03 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;This may have to something with the size of your OUT endpoint.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Typically these are set to multiples of 2, like 64 or 512.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You find that information in the USB endpoint descriptor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now if you tranfser a larger block like 4096 the host splits them into packets of max. size.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If the last packet has less than EPSIZE bytes then this indicates an end of the transfer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this is th reason you see an EP_EVT with 1000 bytes immediatley. The last packet is of less than max size and this particular transfer is considered to be finished.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With 1024 there&amp;nbsp; is no remainder and the transfer continues until the buffer you have set up is full.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I may be wrong, of course.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could test that by setting the OUT endpoint size to an integer fraction of 1000, e.g. 50 instead of 64 or 500 instead of 512. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:37:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554493#M14771</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: USB_EVT_OUT and Buffer Size</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554494#M14772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by etunnel on Fri Sep 19 23:30:31 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you are right.&amp;nbsp; The wMaxPacketSize of the EP is set to be 64 bytes.&amp;nbsp; I experimented with changing the buffer size in the device.&amp;nbsp; This change has no effect on how USB_EVT_OUT event is generated.&amp;nbsp; It must be wMaxPacketSize.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess I have to be careful in constructing the transfer size in order to get somewhat synchronous response from the device.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One interesting observation when using USBD_API-&amp;gt;hw-&amp;gt;ReadEP():&amp;nbsp; If I issue a transfer that is larger than the device buffer, this API cannot read out the data into the buffer at all, but return read size of 0.&amp;nbsp; The device doesn't split the data into two read.&amp;nbsp; At the same time, the host indicates that the transfer is completed successfully.&amp;nbsp; Effectively, the data is lost.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't experimented with the lower level DMA DTD descriptor setup in this case.&amp;nbsp; I hope there is status information about this situation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for this pointer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:37:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554494#M14772</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: USB_EVT_OUT and Buffer Size</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554495#M14773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by etunnel on Tue Sep 23 00:07:43 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I stumbled onto something that is quite useful for this situation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For WinUSB API, there is a policy controlling how data write works as described below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;0x01SHORT_PACKET_TERMINATESends a zero length packet for a write request in which the buffer is a multiple of the maximum packet size supported by the endpoint.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It applies to Bulk (OUT) Interrupt (OUT).&amp;nbsp; By default, it is FALSE.&amp;nbsp; This policy is set with function, WinUsb_SetPipePolicy().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It changed it to be TRUE in my test program.&amp;nbsp; Now, I am getting USB_EVT_OUT event call back just as I originally hoped for.&amp;nbsp; This zero length packet doesn't add on to the read length returned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know what is the performance impact of enabling this.&amp;nbsp; I think the benefit of simplified data packetization algorithm outweighs any performance degradation.&amp;nbsp; I wonder why the default is the other way.&amp;nbsp; Is it due to some USB device's lack of zero length packet support?&amp;nbsp; Anyway, it works for LPC4370.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I imagine there is equivalent capability in libusb API as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:37:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554495#M14773</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: USB_EVT_OUT and Buffer Size</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554496#M14774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mch0 on Tue Sep 23 01:46:02 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason is indeed performance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A ZLP (Zero Length Packet) is another packet on the USB bus, taking some time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is indeed shortened a lot, but nevertheless there is overhead around the "pure token".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For that reason some well-known classes like Mass Storage explicitely do not use ZLP termination. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is most probably also the reason why it is turned off by default in WinUsb.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:37:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/USB-EVT-OUT-and-Buffer-Size/m-p/554496#M14774</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:37:27Z</dc:date>
    </item>
  </channel>
</rss>

