<?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>MQX Software SolutionsのトピックRe: Starting a periodic timer from an ISR?</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386756#M12898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Panpwr,&lt;/P&gt;&lt;P&gt;Short answer:&amp;nbsp; It should be in that document.&lt;/P&gt;&lt;P&gt;I will see about getting it added.&lt;/P&gt;&lt;P&gt;Thank you.&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>Thu, 04 Dec 2014 16:03:46 GMT</pubDate>
    <dc:creator>DavidS</dc:creator>
    <dc:date>2014-12-04T16:03:46Z</dc:date>
    <item>
      <title>Starting a periodic timer from an ISR?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386753#M12895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to use &lt;STRONG&gt;&lt;EM&gt;_timer_start_periodic_every()&lt;/EM&gt;&lt;/STRONG&gt; from within ISR (when a button is pressed), but receives results of TIMER_NULL_ID.&lt;/P&gt;&lt;P&gt;When I am debugging into the function, when reaching &lt;STRONG&gt;_timer_start_periodic_every_internal()&lt;/STRONG&gt;, this function always reaches following condition a&lt;SPAN style="color: #575757;"&gt;nd returns &lt;STRONG&gt;MQX_INVALID_LWSEM &lt;/STRONG&gt;error:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14175335686334241" jivemacro_uid="_14175335686334241"&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Gain exclusive access to the timer queues */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (kernel_data-&amp;gt;ACTIVE_PTR != timer_component_ptr-&amp;gt;TIMER_TD_PTR)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_lwsem_wait(&amp;amp;timer_component_ptr-&amp;gt;TIMER_ENTRIES_LWSEM) != MQX_OK)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _task_set_error(MQX_INVALID_LWSEM);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(TIMER_NULL_ID);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } /* Endif */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } /* Endif */&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the MQX user's guide,&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;_timer_start_&lt;/EM&gt;&lt;/STRONG&gt; functions are not included in "Functions That the ISR Cannot Call" - so it should succeed.&lt;/P&gt;&lt;P&gt;However, from the implementation above, I can see that it calls &lt;STRONG&gt;&lt;EM&gt;_lwsem_wait()&lt;/EM&gt;&lt;/STRONG&gt; which is not allowed in an ISR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my questions:&lt;/P&gt;&lt;P&gt;1. Why can't I allocate a timer from the ISR?&lt;/P&gt;&lt;P&gt;2. If it is because of the &lt;STRONG&gt;&lt;EM&gt;lwsem_wait()&lt;/EM&gt;&lt;/STRONG&gt; usage - then why it is still allowed to use?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Lior.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Dec 2014 15:17:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386753#M12895</guid>
      <dc:creator>panpwr</dc:creator>
      <dc:date>2014-12-02T15:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a periodic timer from an ISR?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386754#M12896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Panpwr,&lt;/P&gt;&lt;P&gt;An ISR routine must not call a function that can block.&lt;/P&gt;&lt;P&gt;In the ISR you can call functions that do not block.&amp;nbsp; Setting an event would be OK.&amp;nbsp; Then in a user task that is blocked waiting for that event, have the code you want ready to run.&lt;/P&gt;&lt;P&gt;Please review section "Handling Interrupts and Exceptions" in "MQX_User_Guid.pdf" in the MQX4.1/doc/mqx path.&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, 02 Dec 2014 15:24:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386754#M12896</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2014-12-02T15:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a periodic timer from an ISR?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386755#M12897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to your answer, I understand that this function obviously should be listed in the user guide, under the section &lt;STRONG&gt;"&lt;/STRONG&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;Functions That the ISR Cannot Call"&lt;/STRONG&gt; as well, correct?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;The question is: Why is it not listed there (only _timer_cancel appear)? Maybe there is an alternative way to use this function in spite of the blocking call?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 08:50:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386755#M12897</guid>
      <dc:creator>panpwr</dc:creator>
      <dc:date>2014-12-03T08:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a periodic timer from an ISR?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386756#M12898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Panpwr,&lt;/P&gt;&lt;P&gt;Short answer:&amp;nbsp; It should be in that document.&lt;/P&gt;&lt;P&gt;I will see about getting it added.&lt;/P&gt;&lt;P&gt;Thank you.&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>Thu, 04 Dec 2014 16:03:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Starting-a-periodic-timer-from-an-ISR/m-p/386756#M12898</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2014-12-04T16:03:46Z</dc:date>
    </item>
  </channel>
</rss>

