<?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中的主题 GPIO Interrupt - MK60N512VMD100</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-Interrupt-MK60N512VMD100/m-p/183003#M1815</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello guys and girls&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm starting into ARM Cortex M4 (Freescale Kinetis). My past experience im uC are all about PIC. I'm facing some difficults into setting/handling an Interruption. A simple one, since it's GPIO related.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on a Freescale TRW-K60N512 module with MK60N512VMD100 processor and Keil u-Vision. This board has 4 LED-TouchElectrode pairs. I'm trying to toggle 2 LEDs by pressing the touch electrodes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, my code is bellow. However, it doesn't work (I get no response from pressing the electrodes).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help please with some more details? For a first, I could not understand how PORTA_IRQHandler could be right handled by the compiler and I could not find any vector address for it. Do I need to declare an address myself?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are the Interrupt usage basic? Setting up (Registers) and then Handling (registers). If anyone has a document about it, or even better, some usage example (using Keil) I would appreciate it a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#include "MK60N512MD100.h"#include "delay.h" #define nLED_E1 11#define nLED_E2 28#define nLED_E3 29#define nLED_E4 10#define nTouch_E1 4#define nTouch_E2 3#define nTouch_E3 2#define nTouch_E4 16#define nSW1_IRQ0 19#define nSW2_IRQ1 26#define LED_E1 (1&amp;lt;&amp;lt;nLED_E1)#define LED_E2 (1&amp;lt;&amp;lt;nLED_E2)#define LED_E3 (1&amp;lt;&amp;lt;nLED_E3)#define LED_E4 (1&amp;lt;&amp;lt;nLED_E4)#define Touch_E1 (1&amp;lt;&amp;lt;nTouch_E1)#define Touch_E2 (1&amp;lt;&amp;lt;nTouch_E2)#define Touch_E3 (1&amp;lt;&amp;lt;nTouch_E3)#define Touch_E4 (1&amp;lt;&amp;lt;nTouch_E4)#define SW1_IRQ0 (1&amp;lt;&amp;lt;nSW1_IRQ0)#define SW2_IRQ1 (1&amp;lt;&amp;lt;nSW2_IRQ1)int main (void) {        SIM-&amp;gt;SCGC5 = SIM-&amp;gt;SCGC5 | SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTE_MASK ;        PORTA-&amp;gt;PCR[nLED_E1] = PORT_PCR_MUX(1);        PORTA-&amp;gt;PCR[nLED_E2] = PORT_PCR_MUX(1);        PORTA-&amp;gt;PCR[nLED_E3] = PORT_PCR_MUX(1);         PORTA-&amp;gt;PCR[nLED_E4] = PORT_PCR_MUX(1);        PORTA-&amp;gt;PCR[nTouch_E1] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;         PORTB-&amp;gt;PCR[nTouch_E2] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;          PORTB-&amp;gt;PCR[nTouch_E3] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;          PORTB-&amp;gt;PCR[nTouch_E4] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;          PORTA-&amp;gt;PCR[nSW1_IRQ0] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK ;        PORTE-&amp;gt;PCR[nSW2_IRQ1] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK ;        PTA-&amp;gt;PDDR = ~GPIO_PDDR_PDD_MASK;          PTB-&amp;gt;PDDR = ~GPIO_PDDR_PDD_MASK;          PTE-&amp;gt;PDDR = ~GPIO_PDDR_PDD_MASK;                  PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E1;          PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E2;         PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E3;         PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E4;         /*--------------------------------------------------------------------------                    Enable interruptions: Falling edge        --------------------------------------------------------------------------*/        PORTA-&amp;gt;PCR[nTouch_E1] |= PORT_PCR_IRQC(10);          PORTB-&amp;gt;PCR[nTouch_E2] |= PORT_PCR_IRQC(10);          PORTB-&amp;gt;PCR[nTouch_E3] |= PORT_PCR_IRQC(10);          PORTB-&amp;gt;PCR[nTouch_E4] |= PORT_PCR_IRQC(10);                    PORTA-&amp;gt;PCR[nSW1_IRQ0] |= PORT_PCR_IRQC(10);           PORTE-&amp;gt;PCR[nSW2_IRQ1] |= PORT_PCR_IRQC(10);           NVIC_EnableIRQ(PORTA_IRQn);        NVIC_EnableIRQ(PORTB_IRQn);        NVIC_EnableIRQ(PORTE_IRQn);        NVIC_SetPriority(PORTA_IRQn,1);        NVIC_SetPriority(PORTB_IRQn,1);        NVIC_SetPriority(PORTE_IRQn,1);                /*--------------------------------------------------------------------------                Turn off LEDs        --------------------------------------------------------------------------*/                PTA-&amp;gt;PSOR = LED_E1 ;           PTA-&amp;gt;PSOR = LED_E2 ;         PTA-&amp;gt;PSOR = LED_E3 ;         PTA-&amp;gt;PSOR = LED_E4 ;        /*--------------------------------------------------------------------------                Main loop        --------------------------------------------------------------------------*/        while (1) {                        Delay_ms (50);                PTA-&amp;gt;PSOR = LED_E2 ;                                                Delay_ms (50);                PTA-&amp;gt;PCOR = LED_E2 ;                        }}void PORTA_IRQHandler(void) {        PORTA-&amp;gt;ISFR = PORT_ISFR_ISF_MASK;        PTA-&amp;gt;PTOR = LED_E3 ;        Delay_ms (500);}void PORTB_IRQHandler(void) {        PORTB-&amp;gt;ISFR = PORT_ISFR_ISF_MASK;        PTA-&amp;gt;PTOR = LED_E4 ;        Delay_ms (500);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fabio de Luca&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:33:57 GMT</pubDate>
    <dc:creator>fabiodeluca</dc:creator>
    <dc:date>2020-10-29T09:33:57Z</dc:date>
    <item>
      <title>GPIO Interrupt - MK60N512VMD100</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-Interrupt-MK60N512VMD100/m-p/183003#M1815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello guys and girls&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm starting into ARM Cortex M4 (Freescale Kinetis). My past experience im uC are all about PIC. I'm facing some difficults into setting/handling an Interruption. A simple one, since it's GPIO related.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on a Freescale TRW-K60N512 module with MK60N512VMD100 processor and Keil u-Vision. This board has 4 LED-TouchElectrode pairs. I'm trying to toggle 2 LEDs by pressing the touch electrodes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, my code is bellow. However, it doesn't work (I get no response from pressing the electrodes).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help please with some more details? For a first, I could not understand how PORTA_IRQHandler could be right handled by the compiler and I could not find any vector address for it. Do I need to declare an address myself?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are the Interrupt usage basic? Setting up (Registers) and then Handling (registers). If anyone has a document about it, or even better, some usage example (using Keil) I would appreciate it a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#include "MK60N512MD100.h"#include "delay.h" #define nLED_E1 11#define nLED_E2 28#define nLED_E3 29#define nLED_E4 10#define nTouch_E1 4#define nTouch_E2 3#define nTouch_E3 2#define nTouch_E4 16#define nSW1_IRQ0 19#define nSW2_IRQ1 26#define LED_E1 (1&amp;lt;&amp;lt;nLED_E1)#define LED_E2 (1&amp;lt;&amp;lt;nLED_E2)#define LED_E3 (1&amp;lt;&amp;lt;nLED_E3)#define LED_E4 (1&amp;lt;&amp;lt;nLED_E4)#define Touch_E1 (1&amp;lt;&amp;lt;nTouch_E1)#define Touch_E2 (1&amp;lt;&amp;lt;nTouch_E2)#define Touch_E3 (1&amp;lt;&amp;lt;nTouch_E3)#define Touch_E4 (1&amp;lt;&amp;lt;nTouch_E4)#define SW1_IRQ0 (1&amp;lt;&amp;lt;nSW1_IRQ0)#define SW2_IRQ1 (1&amp;lt;&amp;lt;nSW2_IRQ1)int main (void) {        SIM-&amp;gt;SCGC5 = SIM-&amp;gt;SCGC5 | SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTE_MASK ;        PORTA-&amp;gt;PCR[nLED_E1] = PORT_PCR_MUX(1);        PORTA-&amp;gt;PCR[nLED_E2] = PORT_PCR_MUX(1);        PORTA-&amp;gt;PCR[nLED_E3] = PORT_PCR_MUX(1);         PORTA-&amp;gt;PCR[nLED_E4] = PORT_PCR_MUX(1);        PORTA-&amp;gt;PCR[nTouch_E1] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;         PORTB-&amp;gt;PCR[nTouch_E2] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;          PORTB-&amp;gt;PCR[nTouch_E3] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;          PORTB-&amp;gt;PCR[nTouch_E4] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK;          PORTA-&amp;gt;PCR[nSW1_IRQ0] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK ;        PORTE-&amp;gt;PCR[nSW2_IRQ1] = PORT_PCR_MUX(1) | PORT_PCR_PE_MASK ;        PTA-&amp;gt;PDDR = ~GPIO_PDDR_PDD_MASK;          PTB-&amp;gt;PDDR = ~GPIO_PDDR_PDD_MASK;          PTE-&amp;gt;PDDR = ~GPIO_PDDR_PDD_MASK;                  PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E1;          PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E2;         PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E3;         PTA-&amp;gt;PDDR = PTA-&amp;gt;PDDR | LED_E4;         /*--------------------------------------------------------------------------                    Enable interruptions: Falling edge        --------------------------------------------------------------------------*/        PORTA-&amp;gt;PCR[nTouch_E1] |= PORT_PCR_IRQC(10);          PORTB-&amp;gt;PCR[nTouch_E2] |= PORT_PCR_IRQC(10);          PORTB-&amp;gt;PCR[nTouch_E3] |= PORT_PCR_IRQC(10);          PORTB-&amp;gt;PCR[nTouch_E4] |= PORT_PCR_IRQC(10);                    PORTA-&amp;gt;PCR[nSW1_IRQ0] |= PORT_PCR_IRQC(10);           PORTE-&amp;gt;PCR[nSW2_IRQ1] |= PORT_PCR_IRQC(10);           NVIC_EnableIRQ(PORTA_IRQn);        NVIC_EnableIRQ(PORTB_IRQn);        NVIC_EnableIRQ(PORTE_IRQn);        NVIC_SetPriority(PORTA_IRQn,1);        NVIC_SetPriority(PORTB_IRQn,1);        NVIC_SetPriority(PORTE_IRQn,1);                /*--------------------------------------------------------------------------                Turn off LEDs        --------------------------------------------------------------------------*/                PTA-&amp;gt;PSOR = LED_E1 ;           PTA-&amp;gt;PSOR = LED_E2 ;         PTA-&amp;gt;PSOR = LED_E3 ;         PTA-&amp;gt;PSOR = LED_E4 ;        /*--------------------------------------------------------------------------                Main loop        --------------------------------------------------------------------------*/        while (1) {                        Delay_ms (50);                PTA-&amp;gt;PSOR = LED_E2 ;                                                Delay_ms (50);                PTA-&amp;gt;PCOR = LED_E2 ;                        }}void PORTA_IRQHandler(void) {        PORTA-&amp;gt;ISFR = PORT_ISFR_ISF_MASK;        PTA-&amp;gt;PTOR = LED_E3 ;        Delay_ms (500);}void PORTB_IRQHandler(void) {        PORTB-&amp;gt;ISFR = PORT_ISFR_ISF_MASK;        PTA-&amp;gt;PTOR = LED_E4 ;        Delay_ms (500);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fabio de Luca&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:33:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-Interrupt-MK60N512VMD100/m-p/183003#M1815</guid>
      <dc:creator>fabiodeluca</dc:creator>
      <dc:date>2020-10-29T09:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: GPIO Interrupt - MK60N512VMD100</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-Interrupt-MK60N512VMD100/m-p/183004#M1816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fabio&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 4 electrode sensors need to be used in touch sensor mode (either together with a Freescale software library or as touch sensor pins) and so are probably not suitable for GPIO interrupts. I would recommend using the push buttons for developing GPIO interrupt operation instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that your code is missing entering the interrupt handlers (PORTA_IRQHandler and&amp;nbsp;PORTB_IRQHandler). There is probabably a function that can be called to associate these with the interrupt vectors. There is in fact one interrupt vector for a port (with up to 32 GPIOs on it) so it may be necessary for it to also filter the GPIOs that have actually changed too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See page 35 ("Port Interrupts") of&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf" rel="nofollow" target="_blank"&gt;http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;for the user interface in the uTasker project which allows assigning an interrupt handler to each GPIO rather than just to each port.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 00:28:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/GPIO-Interrupt-MK60N512VMD100/m-p/183004#M1816</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2012-08-03T00:28:05Z</dc:date>
    </item>
  </channel>
</rss>

