<?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: Using the NMI_b pin as GPIO on KL15 device in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278207#M10113</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be I post the section of my code which is doing the entire thing..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13705866844028055" jivemacro_uid="_13705866844028055" modifiedtitle="true"&gt;
&lt;P&gt;// Save the 1k sector that is to be erased&lt;/P&gt;
&lt;P&gt;memcpy(Buffer,(unsigned long*)(0x400),1024);&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;// Change the byte for FOPT&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Buffer[13]=0xFB;&lt;/P&gt;
&lt;P&gt;//Erase the sector to be written back&lt;/P&gt;
&lt;P&gt;FLASH_EraseSector((unsigned long)(0x400));&lt;/P&gt;
&lt;P&gt;// Write the modified buffer back to the original address&lt;/P&gt;
&lt;P&gt;// *Note: The size here is in long words. 32 bits. 4 bytes. So 256 words = 1024 bytes&lt;/P&gt;
&lt;P&gt;FLASH_ProgramSectionByLongs((unsigned long)(0x400),(unsigned long*)Buffer,256);&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;// Select ALT1(GPIO) function for PTA4&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;PORTA_PCR4 |= PORT_PCR_MUX(1);&lt;/P&gt;
&lt;P&gt;// Setting PTA4 pin as Output&lt;/P&gt;
&lt;P&gt;GPIOA_PDDR |= (0x01&amp;lt;&amp;lt;4);&lt;/P&gt;
&lt;P&gt;// Disable PU and PFE&lt;/P&gt;
&lt;P&gt;PORTA_PCR4 &amp;amp;= (~((0x1&amp;lt;&amp;lt;1)|(0x1&amp;lt;&amp;lt;4)));&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;// Start The toggle loop&lt;/P&gt;
&lt;P&gt;for( ;; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; COMSendStringLine("Toggle");&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // toggle the PTA4 pin&lt;/P&gt;
&lt;P&gt;&amp;nbsp; GPIOA_PCOR |= (0x01&amp;lt;&amp;lt;4); // Clear the pin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; vTaskDelay(1000/portTICK_RATE_MS);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; GPIOA_PSOR |= (0x01&amp;lt;&amp;lt;4); // Set the pin&lt;/P&gt;
&lt;P&gt;&amp;nbsp; vTaskDelay(1000/portTICK_RATE_MS);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;


&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the very first time this block of code is executed, it will not have any effect because the value of the FOPT is loaded from the flash config field during reset. So If I cycle the power to my board one time, it should start working and toggling the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unless there is some mistake in my code &lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 13:05:46 GMT</pubDate>
    <dc:creator>Safwat</dc:creator>
    <dc:date>2020-11-02T13:05:46Z</dc:date>
    <item>
      <title>Using the NMI_b pin as GPIO on KL15 device</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278205#M10111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone. I am working with a 32pin KL15 MCU. I need to disable the NMI_b function on PTA4 and use it as a normal GPIO.&lt;/P&gt;&lt;P&gt;I understand from the reference manual that I need to write to FTFA_FOPT--&amp;gt; NMI_DIS to disable the NMI function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I have done so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Write 0xFB to address 0x0040D in flash configuration field. 0x0040D is the address for FOPT. Writing 0xFB should set 0 in the NMI_DIS bit.&lt;/P&gt;&lt;P&gt;&amp;gt; Verified the written value by reading back the memory.&lt;/P&gt;&lt;P&gt;&amp;gt; Configured PTA4 as a GPIO. Set direction to Output. Disable Passive filter. Disable internal pull up.&lt;/P&gt;&lt;P&gt;&amp;gt; Toggle the pin at 1Hz in a loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I am not able to see any change in the state of PTA4. Can someone help me find what I am missing?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 11:01:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278205#M10111</guid>
      <dc:creator>Safwat</dc:creator>
      <dc:date>2013-06-06T11:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using the NMI_b pin as GPIO on KL15 device</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278206#M10112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Safwat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doesn't sound like you're missing anything right now.&amp;nbsp; Maybe you just have a typo somewhere?&amp;nbsp; Could you post your register values for PORTA_PCR4 and all of the GPIOA_xxx registers just before you start to toggle your pins?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 14:36:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278206#M10112</guid>
      <dc:creator>chris_brown</dc:creator>
      <dc:date>2013-06-06T14:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using the NMI_b pin as GPIO on KL15 device</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278207#M10113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be I post the section of my code which is doing the entire thing..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13705866844028055" jivemacro_uid="_13705866844028055" modifiedtitle="true"&gt;
&lt;P&gt;// Save the 1k sector that is to be erased&lt;/P&gt;
&lt;P&gt;memcpy(Buffer,(unsigned long*)(0x400),1024);&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;// Change the byte for FOPT&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Buffer[13]=0xFB;&lt;/P&gt;
&lt;P&gt;//Erase the sector to be written back&lt;/P&gt;
&lt;P&gt;FLASH_EraseSector((unsigned long)(0x400));&lt;/P&gt;
&lt;P&gt;// Write the modified buffer back to the original address&lt;/P&gt;
&lt;P&gt;// *Note: The size here is in long words. 32 bits. 4 bytes. So 256 words = 1024 bytes&lt;/P&gt;
&lt;P&gt;FLASH_ProgramSectionByLongs((unsigned long)(0x400),(unsigned long*)Buffer,256);&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;// Select ALT1(GPIO) function for PTA4&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;PORTA_PCR4 |= PORT_PCR_MUX(1);&lt;/P&gt;
&lt;P&gt;// Setting PTA4 pin as Output&lt;/P&gt;
&lt;P&gt;GPIOA_PDDR |= (0x01&amp;lt;&amp;lt;4);&lt;/P&gt;
&lt;P&gt;// Disable PU and PFE&lt;/P&gt;
&lt;P&gt;PORTA_PCR4 &amp;amp;= (~((0x1&amp;lt;&amp;lt;1)|(0x1&amp;lt;&amp;lt;4)));&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;// Start The toggle loop&lt;/P&gt;
&lt;P&gt;for( ;; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; COMSendStringLine("Toggle");&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // toggle the PTA4 pin&lt;/P&gt;
&lt;P&gt;&amp;nbsp; GPIOA_PCOR |= (0x01&amp;lt;&amp;lt;4); // Clear the pin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; vTaskDelay(1000/portTICK_RATE_MS);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; GPIOA_PSOR |= (0x01&amp;lt;&amp;lt;4); // Set the pin&lt;/P&gt;
&lt;P&gt;&amp;nbsp; vTaskDelay(1000/portTICK_RATE_MS);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;


&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the very first time this block of code is executed, it will not have any effect because the value of the FOPT is loaded from the flash config field during reset. So If I cycle the power to my board one time, it should start working and toggling the pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unless there is some mistake in my code &lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:05:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278207#M10113</guid>
      <dc:creator>Safwat</dc:creator>
      <dc:date>2020-11-02T13:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using the NMI_b pin as GPIO on KL15 device</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278208#M10114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to enable the clock gate for port A.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 15:25:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278208#M10114</guid>
      <dc:creator>dieterteuchert</dc:creator>
      <dc:date>2013-06-07T15:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using the NMI_b pin as GPIO on KL15 device</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278209#M10115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is already enabled in the startup code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_1370695924514749 jive_macro_code" jivemacro_uid="_1370695924514749"&gt;
&lt;P&gt;/* Enable all of the port clocks. */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK&lt;/P&gt;
&lt;P&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; | SIM_SCGC5_PORTB_MASK&lt;/P&gt;
&lt;P&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; | SIM_SCGC5_PORTC_MASK&lt;/P&gt;
&lt;P&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; | SIM_SCGC5_PORTD_MASK&lt;/P&gt;
&lt;P&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; | SIM_SCGC5_PORTE_MASK );&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am able to use other pins of PORT A without any issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Jun 2013 12:51:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278209#M10115</guid>
      <dc:creator>Safwat</dc:creator>
      <dc:date>2013-06-08T12:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using the NMI_b pin as GPIO on KL15 device</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278210#M10116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Safwat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You aren't configuring PTA4 for a GPIO.&amp;nbsp; PTA4 defaults to the NMI_b functionality which is a MUX value of 0x7 (or b111).&amp;nbsp; So when you execute PORTA_PCR4 |= PORT_PCR_MUX(1); you end up ORing 0b111 with 0b001, which leaves your MUX value in the default state.&amp;nbsp; Try PORTA_PCR4 = PORT_PCR_MUX(1).&amp;nbsp; This way, you also won't have to explicitly disable the pull-up and passive filter. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jun 2013 14:18:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278210#M10116</guid>
      <dc:creator>chris_brown</dc:creator>
      <dc:date>2013-06-10T14:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using the NMI_b pin as GPIO on KL15 device</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278211#M10117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for finding the bug. I think you've nailed it :smileyhappy:. I will test and share the update here as soon as I get near my hardware.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update: If worked after changing it to PORTA_PCR4 = PORT_PCR_MUX(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Safwat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jun 2013 17:38:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-the-NMI-b-pin-as-GPIO-on-KL15-device/m-p/278211#M10117</guid>
      <dc:creator>Safwat</dc:creator>
      <dc:date>2013-06-10T17:38:56Z</dc:date>
    </item>
  </channel>
</rss>

