<?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: GPIO pin as interrupt source KEA-64 in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349912#M17201</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you sure that you haven't made a mistake with the part in question?&lt;/P&gt;&lt;P&gt;The K64 supports port interrupts but the KE (and KEA) don't. These have keyboaad or external IRQ support instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means that there are no registers in the KE (or KEA) matching the ones in the K64 pin interrupt example.&lt;/P&gt;&lt;P&gt;The KEA doesn't need to enable clocks to the ports and the interrupt vectors also don't match, as is the interrupt flag clearing incompatible.&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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Dec 2014 06:34:30 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2014-12-15T06:34:30Z</dc:date>
    <item>
      <title>GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349908#M17197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am looking to setup an interrupt on a pin. I am pretty new to Freecale and was therefore wondering where I could get information on how to set the pin accordingly as well as how to handle the interrupt once it occurs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 08:08:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349908#M17197</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2014-12-14T08:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349909#M17198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isn't the following KEA64 Reference Manual enough?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://cache.freescale.com/files/microcontrollers/doc/ref_manual/KEA64RM.pdf?WT_TYPE=Reference"&gt;http://cache.freescale.com/files/microcontrollers/doc/ref_manual/KEA64RM.pdf?WT_TYPE=Reference&lt;/A&gt;&lt;SPAN&gt; Manuals&amp;amp;WT_VENDOR=FREESCALE&amp;amp;WT_FILE_FORMAT=pdf&amp;amp;WT_ASSET=Documentation&amp;amp;fileExt=.pdf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Yasuhiko Koumoto.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 20:02:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349909#M17198</guid>
      <dc:creator>yasuhikokoumoto</dc:creator>
      <dc:date>2014-12-14T20:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349910#M17199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is a reference of how the IRQ is used in the uTasker project (the KEA-64 has this as port interrupt possibility but limited to a single pin - PTA5 - see further details at the end).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the user interrupt callback (could do anything so it is just an example)&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14185983705723359" jivemacro_uid="_14185983705723359"&gt;
&lt;P&gt;static void irq_handler(void)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnInterruptMessage(OWN_TASK, IRQ_FIRED);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the user interface code to set up an IRQ interrupt (on KE and KEA parts)&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14185983913008760" jivemacro_uid="_14185983913008760"&gt;
&lt;P&gt;INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_type = PORT_INTERRUPT; // identifier to configure port interrupt&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_handler = irq_handler; // handling function&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_priority = PRIORITY_PORT_IRQ_INT; // interrupt priority level&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_port = KE_PORTI; // the port that the interrupt input is on&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_port_bits = KE_PORTI_BIT6; // the IRQ input connected&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON); // interrupt is to be falling edge sensitive&lt;/P&gt;
&lt;P&gt;fnConfigureInterrupt((void *)&amp;amp;interrupt_setup); // configure interrupt&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fnConfigureInterrupt() does the following in the case of these settings:&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_14185984207027552" jivemacro_uid="_14185984207027552"&gt;
&lt;P&gt;static void (*IRQ_handler)(void) = 0; // handler for IRQ&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;unsigned char ucPortPin = SIM_PINSEL_IRQPS_PTI6;&lt;/P&gt;
&lt;P&gt;POWER_UP(0, SIM_SCGC_IRQ); // enable clocks to the external interrupt module&lt;/P&gt;
&lt;P&gt;SIM_PINSEL0 = ((SIM_PINSEL0 &amp;amp; ~(SIM_PINSEL_IRQPS_PTI6)) | ucPortPin); // select the IRQ pin to use&lt;/P&gt;
&lt;P&gt;IRQ_SC = IRQ_SC_IRQPE; // enable IRQ pin function with pull-up&lt;/P&gt;
&lt;P&gt;IRQ_handler = port_interrupt-&amp;gt;int_handler; // enter the application handler&lt;/P&gt;
&lt;P&gt;fnEnterInterrupt(irq_IRQ_ID, port_interrupt-&amp;gt;int_priority, _IRQ_isr); // ensure that the handler is entered&lt;/P&gt;
&lt;P&gt;IRQ_SC |= (IRQ_SC_IRQIE | IRQ_SC_IRQACK); // enable interrupt and reset pending interrupt&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fnEnterInterrupt() enters the IRQ vector into the vector table (in SRAM in this case but can also be fixed in Flash).&lt;/P&gt;&lt;P&gt;To enable the interrupt source in the NVIC it does (in the case of the IRQ):&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IRQ4_7_PRIORITY_REGISTER |= 0xc0000000;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IRQ0_32_SER = 0x00000080;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course the main Cortex interrupt must also be enabled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the IRQ triggers the IRQ handler is called, which resets the IRQ interrupt flag and calls the user's handler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14185984958749333 jive_text_macro jive_macro_code" jivemacro_uid="_14185984958749333" modifiedtitle="true"&gt;
&lt;P&gt;static __interrupt void _IRQ_isr(void)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRQ_SC |= (IRQ_SC_IRQACK);&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // reset the interrupt flag&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (IRQ_handler != 0) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRQ_handler();&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;&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; // call the interrupt handler&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The KEA-64 (as some smaller KE parts) has however only one IRQ input which can only be on PTA5. PTA5 defaults to RESET_b input and to use it the following differences are valid:&lt;/P&gt;&lt;P&gt;- the reset function must be disabled in SIM_SOPT0 [SIM_SOPT0 &amp;amp;= ~(SIM_SOPT_RSTPE);] - this is however a write-once field so it has to be used carefully. It is best to do it immediately after reset (where all such bits are defined together) so that it is guarantied to work.&lt;/P&gt;&lt;P&gt;- The SIM_PINSEL0 operations are redundant since the other sources don't exist&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 href="http://www.utasker.com/kinetis.html" rel="nofollow noopener noreferrer" title="http://www.utasker.com/kinetis.html" target="_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 23:12:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349910#M17199</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-14T23:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349911#M17200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the attached is an pin interrupt example based on K64, the code is similar with that of KEA.&lt;/P&gt;&lt;P&gt;I hope it helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 05:53:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349911#M17200</guid>
      <dc:creator>Rick_Li</dc:creator>
      <dc:date>2014-12-15T05:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349912#M17201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you sure that you haven't made a mistake with the part in question?&lt;/P&gt;&lt;P&gt;The K64 supports port interrupts but the KE (and KEA) don't. These have keyboaad or external IRQ support instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means that there are no registers in the KE (or KEA) matching the ones in the K64 pin interrupt example.&lt;/P&gt;&lt;P&gt;The KEA doesn't need to enable clocks to the ports and the interrupt vectors also don't match, as is the interrupt flag clearing incompatible.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 06:34:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349912#M17201</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-15T06:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349913#M17202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mark, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your endless patience and help. I was reading your previous comment and was wondering, could a keyboard interrupt be used in the same way as a pin interrupt. I'll explain what I'm trying to do and then you could let me know if this may be a valid path to pursue. I am looking to sleep the KEA-64 until a temperature threshold is reached, at this point an interrupt from the sensor should fire and wake the KEA-64 to take action. While one interrupt should work two would be helpful as there is a second interrupt for a critical threshold that may be useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 21:44:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349913#M17202</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2014-12-15T21:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349914#M17203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are more Keyboard interrupts (only one IRQ) and these can wake from sleep modes so this will certainly be more suitable as soon as you need &amp;gt;1 such interrupt.&lt;/P&gt;&lt;P&gt;Unfortunately I can't working KBI code at the moment since I have used it only on the KE04 and KE06, which is a little different to the KE02 (closest to the KEA-64); it is however very similar to the IRQ but with additioanl status flags to indicate which one (or more) if the inputs causes the interrupt.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 22:12:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349914#M17203</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-15T22:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349915#M17204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did not noticed the difference between port interrupt on K64 and KE&amp;amp;KEA.&lt;/P&gt;&lt;P&gt;Thank you so much for your reminder, I will check it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Dec 2014 03:57:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349915#M17204</guid>
      <dc:creator>Rick_Li</dc:creator>
      <dc:date>2014-12-19T03:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349916#M17205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mark, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been looking around but I can not seem to find what the difference is between a KBI and a IRQ. They appear to behave very similarly if not the same, any clarification here would be much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2014 01:37:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349916#M17205</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2014-12-23T01:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349917#M17206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, they are very similar. However when the IRQ triggers you know that the single IRQ pin state has changed to cause the interrupt. In the case of the KBI your know that one of the possible ones triggered the interrupt and then you need to work out which one it was by reading the staus register and resetting it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since further changes can take place when doing the handling it can be a little tricky to ensure than no changes are ever missed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you just need to wake up then it makes it a lot simpler because you can enable multiple KBI inputs/interrupts and you will be woken when any one of them fires.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2014 02:42:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349917#M17206</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-23T02:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Re: GPIO pin as interrupt source KEA-64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349918#M17207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have had the opportunity to work with the KBI as in your device. The first thing to note is that there is a single interrupt for the 8 possible keyboard input interrupts of each of the two KBIs and there is no way to reliably know which one of them interrupted. This means that if any one triggers you know that one of them matched the interrupt requirement and you can read the port inputs (GPIOx_PDIR) to decide what to actually do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The API looks like this (very similar to the IRQ) but referencing to the pins is performed by their port references and not their KBI references (this makes it more flexible).&lt;/P&gt;&lt;P&gt;It alows multiple pins to be configured for KBI use by referencing their port pins and so automatically allows configuring pins across multiple KBI controllers. The example shows 2 pins, whereby one belongs to KBI0 and KBI1, and both have the same user interrupt handler (although they would fire via differnet interrupt vectors),&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_14193853213136121" jivemacro_uid="_14193853213136121" modifiedtitle="true"&gt;
&lt;P&gt;INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_type = PORT_INTERRUPT; // identifier to configure port interrupt&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_handler = test_kbi; // handling function&lt;/P&gt;
&lt;P&gt;// Keyboard&lt;/P&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_type = KEYBOARD_INTERRUPT; // define keyboard interrupt rather than IRQ&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_priority = PRIORITY_KEYBOARD_INT; // interrupt priority level&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_port = KE_PORTD; // the port that the interrupt input is on (KE_PORTA, KE_PORTB, KE_PORTC and KE_PORTD are the same)&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_port_bits = (KE_PORTD_BIT5 | KE_PORTB_BIT3); // the IRQs input connected&lt;/P&gt;
&lt;P&gt;interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON); // interrupt is to be falling edge sensitive&lt;/P&gt;
&lt;P&gt;fnConfigureInterrupt((void *)&amp;amp;interrupt_setup); // configure interrupt&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is some assigning between pins and KBI inputs but basically it does (eg. of the input configured on KBI0_P7, which is PTB3):&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_14193853782172114" jivemacro_uid="_14193853782172114"&gt;
&lt;P&gt;POWER_UP(0, SIM_SCGC_KBI0); // ensure the module is powered&lt;/P&gt;
&lt;P&gt;KBI_handlers[0] = port_interrupt-&amp;gt;int_handler; // enter the user handler for the keyboard interrupt controller&lt;/P&gt;
&lt;P&gt;fnEnterInterrupt(irq_KBI0_ID, port_interrupt-&amp;gt;int_priority, _KBI0_isr);&lt;/P&gt;
&lt;P&gt;PORT_PUEL |= port_interrupt-&amp;gt;int_port_bits; // enabled pull-ups on the specified KBI inputs&lt;/P&gt;
&lt;P&gt;KBI0_SC &amp;amp;= ~KBI_SC_KBIE; // mask main KBI interrupt&lt;/P&gt;
&lt;P&gt;KBI0_SC &amp;amp;= ~KBI_SC_KBMOD; // detect only edges&lt;/P&gt;
&lt;P&gt;KBI0_ES &amp;amp;= ~0x80; // select falling edge interrupt (this is the bit that was mapped between port and KBI pin)&lt;/P&gt;
&lt;P&gt;KBI0_SC |= KBI_SC_KBACK; // clear any false interrupts&lt;/P&gt;
&lt;P&gt;KBI0_PE |= 0x80; // enable the pin as KBI interrupt&lt;/P&gt;
&lt;P&gt;KBI0_SC |= KBI_SC_KBIE;&amp;nbsp; // enable main KBI interrupt&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The interrupt (KBI0) does:&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_14193853969709041" jivemacro_uid="_14193853969709041"&gt;
&lt;P&gt;KBI0_SC |= KBI_SC_KBACK; // clear pending interrupt&lt;/P&gt;
&lt;P&gt;if (KBI_handlers[0] != 0) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; KBI_handlers[0](); // call user handler&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you see it is indeed very similar to the IRQ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Larger devices with more KBI interrupts have a different register set and 32 inputs per KBI controller. The set includes a register informing which of the inputs caused the interrupt and so allows more flexibility to assigning user call-backs to each individual pin interruts if required.&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 href="http://www.utasker.com/kinetis.html" rel="nofollow noopener noreferrer" title="http://www.utasker.com/kinetis.html" target="_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 01:44:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-pin-as-interrupt-source-KEA-64/m-p/349918#M17207</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-24T01:44:16Z</dc:date>
    </item>
  </channel>
</rss>

