<?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>Kinetis MicrocontrollersのトピックRe: USB attach event at code start up</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-attach-event-at-code-start-up/m-p/491492#M30347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-weight: bold; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;EM style="font-weight: inherit; font-family: inherit;"&gt;was working fairly well until we put optimization on in the&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: bold; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;EM style="font-weight: inherit; font-family: inherit;"&gt;code"&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is almost always a sign that the keyword 'volatile' is missing from someplace that it is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The optimizer removes code that it thinks has no side effects, for example reading a register without using the read value.&lt;/P&gt;&lt;P&gt;To the compiler that is wasted time.&amp;nbsp; It does not know that the reading that register actually changes a bit in the register.&lt;/P&gt;&lt;P&gt;'volatile' forces the read or write to happen even if the compiler does not think it is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There can also be the obscure case of Code Motion where memory barrier instructions are required, and missing, to prevent the optimizer from reordering code.&amp;nbsp; For example moving a disable interrupt instruction to someplace it will have no effect.&lt;/P&gt;&lt;P&gt;A lot of inline assembly instructions I see will have this problem, they also need to be marked volatile.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Mar 2016 13:02:55 GMT</pubDate>
    <dc:creator>bobpaddock</dc:creator>
    <dc:date>2016-03-21T13:02:55Z</dc:date>
    <item>
      <title>USB attach event at code start up</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-attach-event-at-code-start-up/m-p/491490#M30345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear NXP community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a customer struggling a little with the Kinetis USB stack.&amp;nbsp; Looks like everything is working except at power up the USB stick isn't always recognized if it is already attached.&amp;nbsp; Here is the note from the customer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;We are using the baremetal USB stack in our SubDrive design&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;(this is in KDS but does not use KSDK).&amp;nbsp; We recently moved it to newer&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;micros and the USB was working fairly well until we put optimization on in the&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;code.&amp;nbsp; We started to get watchdog resets due to the USB stack.&amp;nbsp; We&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;investigated this some and moved the USB_host_init() into the startup&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;components_init() section of the code.&amp;nbsp; The reset issue is resolved, but&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;now it sometimes does not recognize an attached USB thumb drive during power&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;up.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt; &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;We don’t believe the attach event is occurring but don’t&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;understand in the USB stack what generates the attached event.&amp;nbsp; Is there&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;any documentation on what generates this event?&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Anyone have any helpful suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Mar 2016 14:44:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-attach-event-at-code-start-up/m-p/491490#M30345</guid>
      <dc:creator>richl</dc:creator>
      <dc:date>2016-03-19T14:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: USB attach event at code start up</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-attach-event-at-code-start-up/m-p/491491#M30346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The attach event happens when the attach interrupt occurs, with Host mode enabled. Signaled by USB Device pullup&lt;/P&gt;&lt;P&gt;resistor changing the state of DPLUS or DMINUS from 0 to 1 (SE0 to J or K state). so if you found attach event didn't happen, please check if the condition meets. Usually a USB Device should detect the VBUS line and gives the pull-up signal on D+/D- when VBUS line has power, or the device has power from VBUS and give the signal during its initialization, so that the Host may know there is a device attached on the USB bus.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Kan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Mar 2016 03:16:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-attach-event-at-code-start-up/m-p/491491#M30346</guid>
      <dc:creator>Kan_Li</dc:creator>
      <dc:date>2016-03-21T03:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: USB attach event at code start up</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-attach-event-at-code-start-up/m-p/491492#M30347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-weight: bold; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;EM style="font-weight: inherit; font-family: inherit;"&gt;was working fairly well until we put optimization on in the&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: bold; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;EM style="font-weight: inherit; font-family: inherit;"&gt;code"&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is almost always a sign that the keyword 'volatile' is missing from someplace that it is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The optimizer removes code that it thinks has no side effects, for example reading a register without using the read value.&lt;/P&gt;&lt;P&gt;To the compiler that is wasted time.&amp;nbsp; It does not know that the reading that register actually changes a bit in the register.&lt;/P&gt;&lt;P&gt;'volatile' forces the read or write to happen even if the compiler does not think it is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There can also be the obscure case of Code Motion where memory barrier instructions are required, and missing, to prevent the optimizer from reordering code.&amp;nbsp; For example moving a disable interrupt instruction to someplace it will have no effect.&lt;/P&gt;&lt;P&gt;A lot of inline assembly instructions I see will have this problem, they also need to be marked volatile.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Mar 2016 13:02:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-attach-event-at-code-start-up/m-p/491492#M30347</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2016-03-21T13:02:55Z</dc:date>
    </item>
  </channel>
</rss>

