<?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: Short pulse creation and code optimisation in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Short-pulse-creation-and-code-optimisation/m-p/486611#M29944</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, by adding a nop just before the first toggle I was able to manipulate the way the code executed and get just what I needed, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Mar 2016 11:35:51 GMT</pubDate>
    <dc:creator>therealfreegeek</dc:creator>
    <dc:date>2016-03-22T11:35:51Z</dc:date>
    <item>
      <title>Short pulse creation and code optimisation</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Short-pulse-creation-and-code-optimisation/m-p/486609#M29942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create two ~10ns pulses with a separation of ~20ns or so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a FRDM-K64 running at full speed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to get the waveform below with port toggle writes which is close to what I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code is triggered in a PIT interrupt routine and has been working well for a few weeks. The interrupt file "events.c" is optimised in its miscellaneous properties with -O3.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SCRN0037.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/23426i9F1B39281194C049/image-size/large?v=v2&amp;amp;px=999" role="button" title="SCRN0037.PNG" alt="SCRN0037.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The code I use is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GPIOC_PTOR = 0x00010000; // Toggles PortC-16 by writing a 1 to the toggle register port bit&lt;/P&gt;&lt;P&gt;GPIOC_PTOR = 0x00010000; // Toggles PortC-16 by writing a 1 to the toggle register port bit&lt;/P&gt;&lt;P&gt;GPIOC_PTOR = 0x00010000; // Toggles PortC-16 by writing a 1 to the toggle register port bit&lt;/P&gt;&lt;P&gt;GPIOC_PTOR = 0x00010000; // Toggles PortC-16 by writing a 1 to the toggle register port bit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the assembler is;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;00001607:&amp;nbsp;&amp;nbsp; mov.w r2, #65536&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; 0x10000&lt;/P&gt;&lt;P&gt;0000160b:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;0000160d:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;0000160f:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;00001611:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Today I was experimenting with various instructions between the two pulses to create&amp;nbsp; a 20ns delay, but was not able to get anything below 70ns or so, even with just a NOP between the pulses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I went back to my original code and recompiled I ended up with the waveform below and I cant get back to my original.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SCRN0039.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/23427i0DB1CD8F2FA756EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="SCRN0039.PNG" alt="SCRN0039.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Do you have any idea what would cause this to change in this way?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, do you have any suggestions on an instruction that will cause a delay shorter then ~70nS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;00001606:&amp;nbsp;&amp;nbsp; mov.w r2, #65536&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; 0x10000&lt;/P&gt;&lt;P&gt;0000160a:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;0000160c:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;0000160e:&amp;nbsp;&amp;nbsp; nop &lt;/P&gt;&lt;P&gt;00001610:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;00001612:&amp;nbsp;&amp;nbsp; str r2, [r3, #12]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looked like this;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SCRN0040.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/23493i41A71D92CF910785/image-size/large?v=v2&amp;amp;px=999" role="button" title="SCRN0040.PNG" alt="SCRN0040.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 12:31:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Short-pulse-creation-and-code-optimisation/m-p/486609#M29942</guid>
      <dc:creator>therealfreegeek</dc:creator>
      <dc:date>2016-03-18T12:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Short pulse creation and code optimisation</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Short-pulse-creation-and-code-optimisation/m-p/486610#M29943</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;Don't forget that code running from Flash may be subject to changes in execution time depending on the speculation operation and caching. This means that changes to the code 'may' cause routines that you have previously tuned to have quite different timing.&lt;/P&gt;&lt;P&gt;The Flash operates at max. 24MHz and so any faster execution is acheived by these techniques, which are not however guaranteed to be consistent.&lt;/P&gt;&lt;P&gt;I would put special code that requires guaranteed timing behavior in SRAM, where it will run at a higher speed and (probably) be more consistent. You may also prefer to ensure that its operation is excluded from the cache so that it won't have any possibility of jumping around in case the close-coupled cache does allow it to be executed slightly faster in sime circumstances.&lt;/P&gt;&lt;P&gt;Regards&lt;BR /&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 14:31:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Short-pulse-creation-and-code-optimisation/m-p/486610#M29943</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2016-03-18T14:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Short pulse creation and code optimisation</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Short-pulse-creation-and-code-optimisation/m-p/486611#M29944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, by adding a nop just before the first toggle I was able to manipulate the way the code executed and get just what I needed, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2016 11:35:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Short-pulse-creation-and-code-optimisation/m-p/486611#M29944</guid>
      <dc:creator>therealfreegeek</dc:creator>
      <dc:date>2016-03-22T11:35:51Z</dc:date>
    </item>
  </channel>
</rss>

