<?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: Change polarity of an EINT inside it irq routine in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Change-polarity-of-an-EINT-inside-it-irq-routine/m-p/938603#M37395</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;Please check the following code as reference:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/************************************************************/&lt;BR /&gt;/* PROJECT NAME: EXTERNAL INTERRUPT */&lt;BR /&gt;/* Device: LPC2148 */&lt;BR /&gt;/* Filename: ExtInt.c */&lt;BR /&gt;/* Language: C */&lt;BR /&gt;/* Compiler: Keil ARM */&lt;BR /&gt;/* For more detail visit &lt;A href="https://community.nxp.com/www.binaryupdates.com" target="test_blank"&gt;www.binaryupdates.com&lt;/A&gt; */&lt;BR /&gt;/************************************************************/&lt;/P&gt;&lt;P&gt;#include &amp;lt;LPC214x.H&amp;gt;&lt;/P&gt;&lt;P&gt;void delay(int count);&lt;BR /&gt;void init_ext_interrupt(void);&lt;BR /&gt;__irq void Ext_ISR(void);&lt;/P&gt;&lt;P&gt;int main (void) &lt;BR /&gt;{&lt;BR /&gt; init_ext_interrupt(); // initialize the external interrupt&lt;BR /&gt; &lt;BR /&gt; while (1) &lt;BR /&gt; { &lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void init_ext_interrupt() //Initialize Interrupt&lt;BR /&gt;{&lt;BR /&gt; EXTMODE = 0x4; //Edge sensitive mode on EINT2&lt;BR /&gt; &lt;BR /&gt; EXTPOLAR &amp;amp;= ~(0x4); //Falling Edge Sensitive&lt;/P&gt;&lt;P&gt;PINSEL0 = 0x80000000; //Select Pin function P0.15 as EINT2&lt;BR /&gt; &lt;BR /&gt; /* initialize the interrupt vector */&lt;BR /&gt; VICIntSelect &amp;amp;= ~ (1&amp;lt;&amp;lt;16); // EINT2 selected as IRQ 16&lt;BR /&gt; VICVectAddr5 = (unsigned int)Ext_ISR; // address of the ISR&lt;BR /&gt; VICVectCntl5 = (1&amp;lt;&amp;lt;5) | 16; // &lt;BR /&gt; VICIntEnable = (1&amp;lt;&amp;lt;16); // EINT2 interrupt enabled&lt;/P&gt;&lt;P&gt;EXTINT &amp;amp;= ~(0x4); &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;__irq void Ext_ISR(void) // Interrupt Service Routine-ISR &lt;BR /&gt;{&lt;BR /&gt; IO1DIR |= (1&amp;lt;&amp;lt;25);&lt;BR /&gt; IO1CLR |= (1&amp;lt;&amp;lt;25); // Turn ON Buzzer&lt;BR /&gt; delay(100000);&lt;BR /&gt; IO1SET |= (1&amp;lt;&amp;lt;25); // Turn OFF Buzzer&lt;/P&gt;&lt;P&gt;EXTINT |= 0x4; //clear interrupt&lt;BR /&gt; VICVectAddr = 0; // End of interrupt execution&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void delay(int count)&lt;BR /&gt;{&lt;BR /&gt; int j=0,i=0;&lt;/P&gt;&lt;P&gt;for(j=0;j&amp;lt;count;j++)&lt;BR /&gt; {&lt;BR /&gt; /* At 60Mhz, the below loop introduces&lt;BR /&gt; delay of 10 us */&lt;BR /&gt; for(i=0;i&amp;lt;35;i++);&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check more details in the following link:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://binaryupdates.com/external-interrupt-in-lpc2148-arm7/"&gt;https://binaryupdates.com/external-interrupt-in-lpc2148-arm7/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Soledad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Jul 2019 15:46:30 GMT</pubDate>
    <dc:creator>soledad</dc:creator>
    <dc:date>2019-07-22T15:46:30Z</dc:date>
    <item>
      <title>Change polarity of an EINT inside it irq routine</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Change-polarity-of-an-EINT-inside-it-irq-routine/m-p/938602#M37394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can read in the title, I am trying to change the polarity of the edge which causes the external interrupt. I am using an LPC2129.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly I configure it as rising edge sensitive and the VIC vectors registers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;PINSEL1 |= (0&amp;lt;&amp;lt;1) | (1&amp;lt;&amp;lt;0); &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;//Pin P0.16 as EINT0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; EXTMODE |= (1&amp;lt;&amp;lt;0) |; &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; //Edge sensitive&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; EXTPOLAR |= (1&amp;lt;&amp;lt;0) ;&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;//Rising edge&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;VICVectCntl1 = 0x20 |14;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; VICVectAddr1 =(unsigned)EINT0_isr;&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; VICIntEnable |= (1&amp;lt;&amp;lt;14);&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; EXTINT |= (1&amp;lt;&amp;lt;0);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, in the irq routine I want to change to falling edge sensitive, as the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;void EINT0_isr (void) __irq {&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;EXTINT |= (1&amp;lt;&amp;lt;0);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Clear flag&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;...&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; EXTPOLAR &amp;amp;= ~(1&amp;lt;&amp;lt;0); //Change to falling edge&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;...}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This does not work and the program crash.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I read this in the manual but I do not understand how to do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note: Software should only change a bit in this register when its interrupt is&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;disabled in the VICIntEnable register, and should write the corresponding 1 to the&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;EXTINT register before enabling (initializing) or re-enabling the interrupt, to clear&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;the EXTINT bit that could be set by changing the polarity.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I tried to change the code like this but did not work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; VICIntEnClr |= (1&amp;lt;&amp;lt;14);&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; EXTINT |= (1&amp;lt;&amp;lt;0);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; EXTPOLAR &amp;amp;= ~(1&amp;lt;&amp;lt;0);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; VICIntEnable |= (1&amp;lt;&amp;lt;14);&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is the correct way to change edge polarity inside the irq routine of an EINT?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Alessandro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S.: sorry for my english.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2019 09:24:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Change-polarity-of-an-EINT-inside-it-irq-routine/m-p/938602#M37394</guid>
      <dc:creator>alessandromelin</dc:creator>
      <dc:date>2019-07-18T09:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Change polarity of an EINT inside it irq routine</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Change-polarity-of-an-EINT-inside-it-irq-routine/m-p/938603#M37395</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;Please check the following code as reference:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/************************************************************/&lt;BR /&gt;/* PROJECT NAME: EXTERNAL INTERRUPT */&lt;BR /&gt;/* Device: LPC2148 */&lt;BR /&gt;/* Filename: ExtInt.c */&lt;BR /&gt;/* Language: C */&lt;BR /&gt;/* Compiler: Keil ARM */&lt;BR /&gt;/* For more detail visit &lt;A href="https://community.nxp.com/www.binaryupdates.com" target="test_blank"&gt;www.binaryupdates.com&lt;/A&gt; */&lt;BR /&gt;/************************************************************/&lt;/P&gt;&lt;P&gt;#include &amp;lt;LPC214x.H&amp;gt;&lt;/P&gt;&lt;P&gt;void delay(int count);&lt;BR /&gt;void init_ext_interrupt(void);&lt;BR /&gt;__irq void Ext_ISR(void);&lt;/P&gt;&lt;P&gt;int main (void) &lt;BR /&gt;{&lt;BR /&gt; init_ext_interrupt(); // initialize the external interrupt&lt;BR /&gt; &lt;BR /&gt; while (1) &lt;BR /&gt; { &lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void init_ext_interrupt() //Initialize Interrupt&lt;BR /&gt;{&lt;BR /&gt; EXTMODE = 0x4; //Edge sensitive mode on EINT2&lt;BR /&gt; &lt;BR /&gt; EXTPOLAR &amp;amp;= ~(0x4); //Falling Edge Sensitive&lt;/P&gt;&lt;P&gt;PINSEL0 = 0x80000000; //Select Pin function P0.15 as EINT2&lt;BR /&gt; &lt;BR /&gt; /* initialize the interrupt vector */&lt;BR /&gt; VICIntSelect &amp;amp;= ~ (1&amp;lt;&amp;lt;16); // EINT2 selected as IRQ 16&lt;BR /&gt; VICVectAddr5 = (unsigned int)Ext_ISR; // address of the ISR&lt;BR /&gt; VICVectCntl5 = (1&amp;lt;&amp;lt;5) | 16; // &lt;BR /&gt; VICIntEnable = (1&amp;lt;&amp;lt;16); // EINT2 interrupt enabled&lt;/P&gt;&lt;P&gt;EXTINT &amp;amp;= ~(0x4); &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;__irq void Ext_ISR(void) // Interrupt Service Routine-ISR &lt;BR /&gt;{&lt;BR /&gt; IO1DIR |= (1&amp;lt;&amp;lt;25);&lt;BR /&gt; IO1CLR |= (1&amp;lt;&amp;lt;25); // Turn ON Buzzer&lt;BR /&gt; delay(100000);&lt;BR /&gt; IO1SET |= (1&amp;lt;&amp;lt;25); // Turn OFF Buzzer&lt;/P&gt;&lt;P&gt;EXTINT |= 0x4; //clear interrupt&lt;BR /&gt; VICVectAddr = 0; // End of interrupt execution&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void delay(int count)&lt;BR /&gt;{&lt;BR /&gt; int j=0,i=0;&lt;/P&gt;&lt;P&gt;for(j=0;j&amp;lt;count;j++)&lt;BR /&gt; {&lt;BR /&gt; /* At 60Mhz, the below loop introduces&lt;BR /&gt; delay of 10 us */&lt;BR /&gt; for(i=0;i&amp;lt;35;i++);&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check more details in the following link:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://binaryupdates.com/external-interrupt-in-lpc2148-arm7/"&gt;https://binaryupdates.com/external-interrupt-in-lpc2148-arm7/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Soledad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2019 15:46:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Change-polarity-of-an-EINT-inside-it-irq-routine/m-p/938603#M37395</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2019-07-22T15:46:30Z</dc:date>
    </item>
  </channel>
</rss>

