<?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 Design Studio中的主题 Re: How to have delay without using library?</title>
    <link>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540952#M6985</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Attached is Bare Metal code that does ms and us delays that uses no libraries or frame works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Putting long delays, like a second for the user, is rarely the best approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Investigate how to use the SysTic timer for doing delays without busy loops such as the attached uses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look up Cooperative Multitasking.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Jul 2016 12:32:43 GMT</pubDate>
    <dc:creator>bobpaddock</dc:creator>
    <dc:date>2016-07-27T12:32:43Z</dc:date>
    <item>
      <title>How to have delay without using library?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540949#M6982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;I'm a newbie in terms of using freedom boards so i really need your help to do this. I'm currently using FRDM-KL26Z128VLH4 and i need to have delays in my code for at least 1 second or more (depends on the user). The problem is i need to do this without using library so that i can determine how it works. So, if there is anyone here that can help me please help. Any help is appreciated.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Thank you very much!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Best Regards,&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Ken&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2016 11:09:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540949#M6982</guid>
      <dc:creator>hunter18</dc:creator>
      <dc:date>2016-07-26T11:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to have delay without using library?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540950#M6983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ken,&lt;/P&gt;&lt;P&gt;I suggest grabbing the KSDK_v2 for the FRDM-KL26Z:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.nxp.com/products/software-and-tools/run-time-software/kinetis-software-and-tools/development-platforms-with-mbed/software-development-kit-for-kinetis-mcus:KINETIS-SDK?tid=redKINETIS_SDK" title="http://www.nxp.com/products/software-and-tools/run-time-software/kinetis-software-and-tools/development-platforms-with-mbed/software-development-kit-for-kinetis-mcus:KINETIS-SDK?tid=redKINETIS_SDK"&gt;Software Development Kit for Kinetis MCUs|NXP&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can use the KDS_3.2 to open the following low power timer example:&lt;/P&gt;&lt;P&gt;C:\NXP\KSDK_v2\SDK_2.0_FRDM-KL26Z_KDS\boards\frdmkl26z\driver_examples\lptmr\kds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example is setting up LPTMR to interrupt every second.&amp;nbsp; That can be changed to whatever time you want more or less.&lt;/P&gt;&lt;P&gt;By default the LPTMR is using a 1000Hz input clock and the compare register field is set to 1000 (0x3e8).&amp;nbsp; Once the LPTMR starts clocking, 1 second later it generates an interrupt.&amp;nbsp; In the ISR you can disable the LPTMR to prevent repeated interrupts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lastly there is a text file to help with understanding of the example:&lt;/P&gt;&lt;P&gt;C:\NXP\KSDK_v2\SDK_2.0_FRDM-KL26Z_KDS\boards\frdmkl26z\driver_examples\lptmr\readme.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2016 19:15:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540950#M6983</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-07-26T19:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to have delay without using library?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540951#M6984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ken,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David's suggestion is good .&lt;/P&gt;&lt;P&gt;Also you can create PE project on KDS, then add the component of&amp;nbsp; "TimerInt_ldd",configuration the&amp;nbsp; Interrupt period to 1ms，&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;IMG alt="pastedImage_0.png" src="https://community.nxp.com/t5/image/serverpage/image-id/37121iA104EB8F58AB200D/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_0.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14695884525308208 jive_macro_code jive_text_macro" data-renderedposition="743.9833374023438_8_1098_96" jivemacro_uid="_14695884525308208"&gt;&lt;P&gt;void delayms(int t)&lt;/P&gt;&lt;P&gt;{ &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EventCount = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(t &amp;gt; EventCount);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;In the timer interrupt function :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14695884663722410 jive_text_macro" data-renderedposition="891.9833374023438_8_1098_96" jivemacro_uid="_14695884663722410" modifiedtitle="true"&gt;&lt;P&gt;void TU2_OnCounterRestart(LDD_TUserData *UserDataPtr)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Write your code here ... */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;&amp;nbsp; EventCount++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Increment counter of events */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;We can use the delay function :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14695885730365278 jive_text_macro" data-renderedposition="1039.9833984375_8_1098_64" jivemacro_uid="_14695885730365278"&gt;&lt;P&gt;void main ()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; delayms(20*1000);&amp;nbsp; // delay 20s&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:36:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540951#M6984</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2020-11-02T13:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to have delay without using library?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540952#M6985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Attached is Bare Metal code that does ms and us delays that uses no libraries or frame works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Putting long delays, like a second for the user, is rarely the best approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Investigate how to use the SysTic timer for doing delays without busy loops such as the attached uses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look up Cooperative Multitasking.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jul 2016 12:32:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540952#M6985</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2016-07-27T12:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to have delay without using library?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540953#M6986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bob Paddock,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply. I put the function delay_ms() from delay.c and it works. Now, i currently investigating how can i make SysTick working. Do you know how to implement it? if it is okay to you, can you help me to make SysTick work? i don't ask for a code just tell me the step by step procedure on how to implement it. Honestly i don't understand the function of SysTick such as SysTick_CTRL_COUNTFLAG_Pos, SysTick_CTRL_COUNTFLAG_Msk, SysTick_CTRL_CLKSOURCE_Pos, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope you can help me again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You,&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 02:02:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540953#M6986</guid>
      <dc:creator>hunter18</dc:creator>
      <dc:date>2016-07-28T02:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to have delay without using library?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540954#M6987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;System Tick is a timer meant to be a base ticker for the system.&lt;/P&gt;&lt;P&gt;In a simple system it will just increment a value.&amp;nbsp; In a complex RTOS system it will be part of the task scheduler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The registers you mention configure the base tick time, typically 10ms and enable a clock source that gets divided down to get the 100 Hz/ 10 ms tick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example code is attached.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 12:16:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/How-to-have-delay-without-using-library/m-p/540954#M6987</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2016-07-28T12:16:38Z</dc:date>
    </item>
  </channel>
</rss>

