<?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>topic Re: usb odd even buffer descriptors in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/usb-odd-even-buffer-descriptors/m-p/786532#M13486</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know what NXP part you mentioned. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Aug 2018 04:50:03 GMT</pubDate>
    <dc:creator>miduo</dc:creator>
    <dc:date>2018-08-15T04:50:03Z</dc:date>
    <item>
      <title>usb odd even buffer descriptors</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/usb-odd-even-buffer-descriptors/m-p/786531#M13485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am sending data stream from usb bulk endpoint. I am reading the data but it is not in right order. Sometimes i am getting two ODD or EVEN buffers simultaneously. It should be EVEN then ODD, then EVEN again etc. I don't know what i have done wrong. Here is the code.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// BULK Endpoint TX interrupt handler&lt;BR /&gt;static void bulk_ep_handler( BYTE stat )&lt;BR /&gt;{&lt;BR /&gt; volatile BUF_DESC *buf_desc;&lt;BR /&gt; bool odd;&lt;/P&gt;&lt;P&gt;odd = ODD_STAT(stat);&lt;/P&gt;&lt;P&gt;// Next alternate buffer&lt;BR /&gt; EndPoint[EP1].tx_evenBD = (BYTE)(odd ^ BD_ODD);&lt;/P&gt;&lt;P&gt;// OWN the buffer descriptor on which we received the&lt;BR /&gt; // data transfer acknowledgement&lt;BR /&gt; buf_desc = TX_BUF_DESC( EP1, odd );&lt;BR /&gt; buf_desc-&amp;gt;Stat._byte = 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void usb_write_stream(BYTE *buf, DWORD buf_len)&lt;BR /&gt;{&lt;BR /&gt; volatile BUF_DESC *buf_desc;&lt;BR /&gt; BYTE status;&lt;BR /&gt; BYTE next_buf;&lt;/P&gt;&lt;P&gt;status = get_ep1_tx_transfer_status();&lt;BR /&gt; if( status == USB_STATUS_IDLE )&lt;BR /&gt; {&lt;BR /&gt; next_buf = select_ep1_tx_buffer_desc();&lt;/P&gt;&lt;P&gt;buf_desc = TX_BUF_DESC( EP1, next_buf );&lt;BR /&gt; buf_desc-&amp;gt;Count = TO_LE16( ((WORD)buf_len) );&lt;BR /&gt; buf_desc-&amp;gt;Addr = TO_LE32( ((DWORD)buf) );&lt;/P&gt;&lt;P&gt;ready_tx_buffer( EP1, next_buf );&lt;/P&gt;&lt;P&gt;// Toggle DATA0/1 flag on the endpoint&lt;BR /&gt; EndPoint[EP1].tx_DTS ^= DATA1_DTS;&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;static BYTE get_ep1_tx_transfer_status()&lt;BR /&gt;{&lt;BR /&gt; BYTE ep_ctl;&lt;BR /&gt; volatile BUF_DESC *even_desc;&lt;BR /&gt; volatile BUF_DESC *odd_desc;&lt;BR /&gt; BYTE status = USB_STATUS_IDLE;&lt;/P&gt;&lt;P&gt;ep_ctl = MCF_USB_OTG_ENDPT( EP1 );&lt;/P&gt;&lt;P&gt;if( (ep_ctl &amp;amp; (MCF_USB_OTG_ENDPT_EP_TX_EN | MCF_USB_OTG_ENDPT_EP_RX_EN)) == 0 )&lt;BR /&gt; {&lt;BR /&gt; status = USB_STATUS_DISABLED;&lt;BR /&gt; }&lt;BR /&gt; else if( ep_ctl &amp;amp; MCF_USB_OTG_ENDPT_EP_STALL )&lt;BR /&gt; {&lt;BR /&gt; status = USB_STATUS_STALLED;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; even_desc = TX_BUF_DESC( EP1, BD_EVEN );&lt;BR /&gt; odd_desc = TX_BUF_DESC( EP1, BD_ODD );&lt;/P&gt;&lt;P&gt;if( (even_desc-&amp;gt;Stat.SieCtlBit.OWN == 1) || (odd_desc-&amp;gt;Stat.SieCtlBit.OWN == 1) )&lt;BR /&gt; {&lt;BR /&gt; status = USB_STATUS_TRANSFER_IN_PROGRESS;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return status;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;static BYTE select_ep1_tx_buffer_desc()&lt;BR /&gt;{&lt;BR /&gt; volatile BUF_DESC *buf_desc;&lt;BR /&gt; BYTE buf;&lt;BR /&gt; DWORD ctl;&lt;/P&gt;&lt;P&gt;/* Find out which buffer shall be used. */&lt;BR /&gt; buf_desc = TX_BUF_DESC( EP1, BD_EVEN );&lt;BR /&gt; ctl = buf_desc-&amp;gt;Stat._byte &amp;amp; _SIE_OWN;&lt;/P&gt;&lt;P&gt;buf_desc = TX_BUF_DESC( EP1, BD_ODD );&lt;BR /&gt; ctl |= ((buf_desc-&amp;gt;Stat._byte &amp;amp; _SIE_OWN) &amp;lt;&amp;lt; 1);&lt;/P&gt;&lt;P&gt;switch( ctl )&lt;BR /&gt; {&lt;BR /&gt; case 0:&lt;BR /&gt; {&lt;BR /&gt; /* No buffer is used by the USB module. Fill the one&lt;BR /&gt; we think is the next. */&lt;BR /&gt; buf = EndPoint[EP1].tx_evenBD;&lt;BR /&gt; EndPoint[EP1].tx_evenBD ^= BD_ODD;&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;case _SIE_OWN:&lt;BR /&gt; {&lt;BR /&gt; /* Buffer 0 is used by the USB. */&lt;BR /&gt; buf = BD_ODD;&lt;BR /&gt; EndPoint[EP1].tx_evenBD = BD_EVEN;&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;case (_SIE_OWN &amp;lt;&amp;lt; 1):&lt;BR /&gt; {&lt;BR /&gt; /* Buffer 1 is used by the USB. */&lt;BR /&gt; buf = BD_EVEN;&lt;BR /&gt; EndPoint[EP1].tx_evenBD = BD_ODD;&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;default:&lt;BR /&gt; buf = BD_UNKNOWN;&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return buf;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:02:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/usb-odd-even-buffer-descriptors/m-p/786531#M13485</guid>
      <dc:creator>salman83</dc:creator>
      <dc:date>2018-08-14T15:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: usb odd even buffer descriptors</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/usb-odd-even-buffer-descriptors/m-p/786532#M13486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know what NXP part you mentioned. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2018 04:50:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/usb-odd-even-buffer-descriptors/m-p/786532#M13486</guid>
      <dc:creator>miduo</dc:creator>
      <dc:date>2018-08-15T04:50:03Z</dc:date>
    </item>
  </channel>
</rss>

