<?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: Clear Status Flags during ISR in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Clear-Status-Flags-during-ISR/m-p/689046#M42407</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't set a priority of each interrupt it will have the default. It is not usually a problem to not set priorities because like that they will all have the same and simply won't be able to interrupt each other; normally this is fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to check each peripheral's method of clearing interrupts - some need a read before resetting a flag. Some just need a flag reset (writing 0 or 1, again depending on the peripheral) and some are self-clearing when data is read, for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The PIT example may be overly simple because there are multiple PIT channels in the KL26 and so there may be more than one that has interrupted at the same time; the code should check the ones that need handling.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis%2FFRDM-KL26Z.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL26Z.html&lt;/A&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis%2FTEENSY_LC.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis/TEENSY_LC.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 May 2017 21:03:36 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2017-05-22T21:03:36Z</dc:date>
    <item>
      <title>Clear Status Flags during ISR</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Clear-Status-Flags-during-ISR/m-p/689045#M42406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using a MKL26Z128VLH4 &amp;nbsp;(I'm using KSDK 2.2 and MCUXpresso 10.0) in a application where I have multiple peripherals working in a interrupt based fashion&amp;nbsp;and I have a copuple of questions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. When multiple peripherals operating in interrupt mode is it necessary to set-up interrupt priorities&amp;nbsp;by using NVIC?&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;NVIC_SetPriority &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. After looking at the examples for various peripherals I see that in several peripherals the source of the interrupt is not cleared during the ISR, such as UART example&amp;nbsp;&lt;STRONG&gt;\boards\frdmkl26z\driver_examples\uart\interrupt.&amp;nbsp;&lt;/STRONG&gt;Is that kind of usage correct? I thought that interrupt source needs to be cleared prior to exiting the ISR to avoid having false re-entry. Or is reading back the status register somehow automatically clears pending interrupt source flags?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, for instance, during the&amp;nbsp;PIT interrupt is the following piece of code correct? Or should I do a read on status before clearing the flag? I'm a bit confused on general guidelines for correctly exiting the ISRs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/*!
 * @brief Interrupt handler for timer
 */&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; PIT_IRQHandler &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PIT_ClearStatusFlags &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PIT&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; kPIT_Chnl_1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; kPIT_TimerFlag&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PIT_StopTimer &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PIT&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; kPIT_Chnl_1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 May 2017 17:42:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Clear-Status-Flags-during-ISR/m-p/689045#M42406</guid>
      <dc:creator>whata</dc:creator>
      <dc:date>2017-05-22T17:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Clear Status Flags during ISR</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Clear-Status-Flags-during-ISR/m-p/689046#M42407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't set a priority of each interrupt it will have the default. It is not usually a problem to not set priorities because like that they will all have the same and simply won't be able to interrupt each other; normally this is fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to check each peripheral's method of clearing interrupts - some need a read before resetting a flag. Some just need a flag reset (writing 0 or 1, again depending on the peripheral) and some are self-clearing when data is read, for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The PIT example may be overly simple because there are multiple PIT channels in the KL26 and so there may be more than one that has interrupted at the same time; the code should check the ones that need handling.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis%2FFRDM-KL26Z.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL26Z.html&lt;/A&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis%2FTEENSY_LC.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis/TEENSY_LC.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 May 2017 21:03:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Clear-Status-Flags-during-ISR/m-p/689046#M42407</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-05-22T21:03:36Z</dc:date>
    </item>
  </channel>
</rss>

