<?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: KL17 Disable _NMI during boot only?</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Disable-NMI-during-boot-only/m-p/1031302#M56526</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mitchell&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you disable the NMI via the flash options (&lt;EM&gt;may be due to the debugger you use not allowing you to program the pattern - check it with the memory viewer&lt;/EM&gt;) you &lt;SPAN style="text-decoration: underline;"&gt;will not be able to later use it for your application&lt;/SPAN&gt; - therefore you can't disable it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need instead to handle the (spurious) NMI and in its default handler reconfigure the pin's function so that no more NMIs occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Later, when the input is stable and you want to use it you can reconfigure it for the NMI function and install a different NMI handle according to your application requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the code to do this from the uTasker KL17 project.&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;EM&gt;[uTasker project developer for Kinetis and i.MX RT]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;// Default NMI interrupt in vector table&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;//&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; __interrupt &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;irq_NMI&lt;/SPAN&gt;&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;
    &lt;SPAN class="comment token"&gt;// This is executed immediately out of reset if the NMI line is enabled and held low&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;//&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;_CONFIG_PORT_INPUT_FAST_LOW&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;A&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; PORTA_BIT4&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; PORT_PS_UP_ENABLE&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;       &lt;SPAN class="comment token"&gt;// set the NMI line to an input to remove the NMI function and allow the processor to continue&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;


&lt;SPAN class="comment token"&gt;// Allow the user to enter an NMI handler, ensuring that the NMI pin is configured as NMI function&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// - note that the NMI may not have been disabled to allow this to work&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;//&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;extern&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fnEnterNMI&lt;/SPAN&gt;&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="operator token"&gt;*&lt;/SPAN&gt;_NMI_handler&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    VECTOR_TABLE &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;ptrVect &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;VECTOR_TABLE &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;VECTOR_TABLE_OFFSET_REG&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    ptrVect&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;ptrNMI &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; _NMI_handler&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                       &lt;SPAN class="comment token"&gt;// enter interrupt handler&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;_CONFIG_PERIPHERAL&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;A&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PA_4_NMI &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt; PORT_PS_UP_ENABLE&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="comment token"&gt;// enable the NMI function on the pin&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;/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;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>Sun, 02 Feb 2020 19:42:35 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2020-02-02T19:42:35Z</dc:date>
    <item>
      <title>KL17 Disable _NMI during boot only?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Disable-NMI-during-boot-only/m-p/1031301#M56525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey there NXP community, I could use some help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been attempting to get _NMI to be disabled during boot, to no avail.&lt;/P&gt;&lt;P&gt;I've looked at:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/350133"&gt;Disable NMI_b pin/interrupt KL04Z?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/495335"&gt;How to configure Flash Configuration setting from program to protect/un-protect the FRDM-K82F Board?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and of course the manual:&amp;nbsp;&lt;A class="link-titled" href="http://cache.freescale.com/files/32bit/doc/ref_manual/KL17P64M48SF6RM.pdf" title="http://cache.freescale.com/files/32bit/doc/ref_manual/KL17P64M48SF6RM.pdf"&gt;http://cache.freescale.com/files/32bit/doc/ref_manual/KL17P64M48SF6RM.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my scenario, I'm using _NMI for another IC to wake the MCU and begin interaction. With debugger attached (using openOCD debugger if it matters) I have no problems, I assume because _NMI is stable in the high state. However, when I remove the debugger and plug it in, the app never starts. I'm assuming this is due to _NMI triggering. I've attempted editing the Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFF3FFE}; field in startup, but no matter what I do, FOPT is coming back with 0xFF (as inspected through the debugger).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what I need, I need _NMI to be disabled during initial bootup, and (to my understanding) for it to be enabled after initial boot so it can wake the mcu from sleep. What am I missing here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See:&lt;/P&gt;&lt;P&gt;With debugger attached, you can see the app come alive (pin goes high). Then the external IC signals _NMI periodically. No problems.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="with_debugger.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/100491i9F570C7F1498F4BF/image-size/large?v=v2&amp;amp;px=999" role="button" title="with_debugger.png" alt="with_debugger.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No debugger attached, there is a short assert of _NMI, and the app never starts. (Note the quick assertion of _NMI at VCC on does happen with debugger attached too, but it doesn't matter because it is stable when debug is launched).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="NO_DEBUGGER.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/100536i8B111731011D6283/image-size/large?v=v2&amp;amp;px=999" role="button" title="NO_DEBUGGER.png" alt="NO_DEBUGGER.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Feb 2020 00:22:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Disable-NMI-during-boot-only/m-p/1031301#M56525</guid>
      <dc:creator>mitch1</dc:creator>
      <dc:date>2020-02-02T00:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: KL17 Disable _NMI during boot only?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Disable-NMI-during-boot-only/m-p/1031302#M56526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mitchell&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you disable the NMI via the flash options (&lt;EM&gt;may be due to the debugger you use not allowing you to program the pattern - check it with the memory viewer&lt;/EM&gt;) you &lt;SPAN style="text-decoration: underline;"&gt;will not be able to later use it for your application&lt;/SPAN&gt; - therefore you can't disable it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need instead to handle the (spurious) NMI and in its default handler reconfigure the pin's function so that no more NMIs occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Later, when the input is stable and you want to use it you can reconfigure it for the NMI function and install a different NMI handle according to your application requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the code to do this from the uTasker KL17 project.&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;EM&gt;[uTasker project developer for Kinetis and i.MX RT]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;// Default NMI interrupt in vector table&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;//&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; __interrupt &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;irq_NMI&lt;/SPAN&gt;&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;
    &lt;SPAN class="comment token"&gt;// This is executed immediately out of reset if the NMI line is enabled and held low&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;//&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;_CONFIG_PORT_INPUT_FAST_LOW&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;A&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; PORTA_BIT4&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; PORT_PS_UP_ENABLE&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;       &lt;SPAN class="comment token"&gt;// set the NMI line to an input to remove the NMI function and allow the processor to continue&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;


&lt;SPAN class="comment token"&gt;// Allow the user to enter an NMI handler, ensuring that the NMI pin is configured as NMI function&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// - note that the NMI may not have been disabled to allow this to work&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;//&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;extern&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fnEnterNMI&lt;/SPAN&gt;&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="operator token"&gt;*&lt;/SPAN&gt;_NMI_handler&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    VECTOR_TABLE &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;ptrVect &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;VECTOR_TABLE &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;VECTOR_TABLE_OFFSET_REG&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    ptrVect&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;ptrNMI &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; _NMI_handler&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                       &lt;SPAN class="comment token"&gt;// enter interrupt handler&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;_CONFIG_PERIPHERAL&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;A&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PA_4_NMI &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt; PORT_PS_UP_ENABLE&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="comment token"&gt;// enable the NMI function on the pin&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;/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;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>Sun, 02 Feb 2020 19:42:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Disable-NMI-during-boot-only/m-p/1031302#M56526</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2020-02-02T19:42:35Z</dc:date>
    </item>
  </channel>
</rss>

