<?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 LPC1833 missing USB handshake in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1833-missing-USB-handshake/m-p/524800#M7436</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcware_user on Thu Mar 20 03:51:01 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;we are using a LPC1833 with USB0. The firmware is running well, but after some hours data gets lost for an OUT endpoint.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The SetConfig callback will configure the needed endpoints and sets internal states. OUT buffer is primed the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;very first time:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
......
// prime OUT transfer very first time to start the FSM
DataOUTBuff[0].State = DATA_OUT_STATE_PRIMED;
OUTPrimeIdx = 0;
OUTProcIdx = 0;
DcdDataTransfer ( 0, USB_PHYEP_DATA_OUT, (u8_t*)&amp;amp;DataOUTBuff[0].Data[0], 512);
......
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The main processing loop sceleton will use two OUT buffers alternating. When data is received the ISR will&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set the primed buffer state to DATA_OUT_STATE_RCVD so the loop will see that data is present.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
void&amp;nbsp; USBOUTDATA_Process ( void)
{
static u32_t&amp;nbsp; *usb_buff = NULL;


switch ( DataOUTBuff[OUTProcIdx].State)
{
case DATA_OUT_STATE_IDLE:
// wait until device is configured, this state is only for startup.
// USBDATA_Init() will start the FSM
break;


case DATA_OUT_STATE_PRIMED:
// wait for data packet from host. When data received the ISR callback
// will set the state to DATA_OUT_STATE_RCVD.
break;


 case DATA_OUT_STATE_RCVD:
// data received on buffer X.
// before we will start processing this buffer, prime the other buffer for new transfer
OUTPrimeIdx = OUTProcIdx ^ 1;
DataOUTBuff[OUTPrimeIdx].State = DATA_OUT_STATE_PRIMED;
DcdDataTransfer ( 0, USB_PHYEP_DATA_OUT, (u8_t*)&amp;amp;DataOUTBuff[OUTPrimeIdx].Data[0], 512);

// set this buffer to processing
DataOUTBuff[OUTProcIdx].State = DATA_OUT_STATE_PROC;
usb_buff = &amp;amp;DataOUTBuff[OUTProcIdx].Data[0];&amp;nbsp; // initialize data pointer

// fall through
// break;


case DATA_OUT_STATE_PROC:
// process data buffer
......
if ( data_finished)
{
// go to other buffer
OUTProcIdx ^= 1;
return;
}

break;
}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The firmware is running fine for about one to eight hours. Under unknown circumstances an OUT packet&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets lost by the USB device controller. I have added a screenshot from an USB protocol analyzer. For a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;short period of time the USB endpoint is not working correctly. The packet in the blue marked transaction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets lost cause of a missing IRQ. I can force this behavior by disabling the endpoint. I have spent some&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;days to find the bug but i am now out of ideas. I hope this is not a silicon errata. At this time a test is&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;running using two different endpoints. EP 2 for OUT and EP 3 for IN. In the past i used EP 2 for both&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;directions (IN and OUT).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lpcware_user&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:51:44 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:51:44Z</dc:date>
    <item>
      <title>LPC1833 missing USB handshake</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1833-missing-USB-handshake/m-p/524800#M7436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcware_user on Thu Mar 20 03:51:01 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;we are using a LPC1833 with USB0. The firmware is running well, but after some hours data gets lost for an OUT endpoint.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The SetConfig callback will configure the needed endpoints and sets internal states. OUT buffer is primed the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;very first time:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
......
// prime OUT transfer very first time to start the FSM
DataOUTBuff[0].State = DATA_OUT_STATE_PRIMED;
OUTPrimeIdx = 0;
OUTProcIdx = 0;
DcdDataTransfer ( 0, USB_PHYEP_DATA_OUT, (u8_t*)&amp;amp;DataOUTBuff[0].Data[0], 512);
......
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The main processing loop sceleton will use two OUT buffers alternating. When data is received the ISR will&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set the primed buffer state to DATA_OUT_STATE_RCVD so the loop will see that data is present.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
void&amp;nbsp; USBOUTDATA_Process ( void)
{
static u32_t&amp;nbsp; *usb_buff = NULL;


switch ( DataOUTBuff[OUTProcIdx].State)
{
case DATA_OUT_STATE_IDLE:
// wait until device is configured, this state is only for startup.
// USBDATA_Init() will start the FSM
break;


case DATA_OUT_STATE_PRIMED:
// wait for data packet from host. When data received the ISR callback
// will set the state to DATA_OUT_STATE_RCVD.
break;


 case DATA_OUT_STATE_RCVD:
// data received on buffer X.
// before we will start processing this buffer, prime the other buffer for new transfer
OUTPrimeIdx = OUTProcIdx ^ 1;
DataOUTBuff[OUTPrimeIdx].State = DATA_OUT_STATE_PRIMED;
DcdDataTransfer ( 0, USB_PHYEP_DATA_OUT, (u8_t*)&amp;amp;DataOUTBuff[OUTPrimeIdx].Data[0], 512);

// set this buffer to processing
DataOUTBuff[OUTProcIdx].State = DATA_OUT_STATE_PROC;
usb_buff = &amp;amp;DataOUTBuff[OUTProcIdx].Data[0];&amp;nbsp; // initialize data pointer

// fall through
// break;


case DATA_OUT_STATE_PROC:
// process data buffer
......
if ( data_finished)
{
// go to other buffer
OUTProcIdx ^= 1;
return;
}

break;
}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The firmware is running fine for about one to eight hours. Under unknown circumstances an OUT packet&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets lost by the USB device controller. I have added a screenshot from an USB protocol analyzer. For a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;short period of time the USB endpoint is not working correctly. The packet in the blue marked transaction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets lost cause of a missing IRQ. I can force this behavior by disabling the endpoint. I have spent some&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;days to find the bug but i am now out of ideas. I hope this is not a silicon errata. At this time a test is&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;running using two different endpoints. EP 2 for OUT and EP 3 for IN. In the past i used EP 2 for both&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;directions (IN and OUT).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lpcware_user&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:51:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1833-missing-USB-handshake/m-p/524800#M7436</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:51:44Z</dc:date>
    </item>
  </channel>
</rss>

