title: Multiple External Interrupt on LPC1768 : only one interrupt is working
body: <p>I've wrote code for external interrupt EINT1.  That works, but if I want to add a second interrupt (EINT3), only the new works.  I can have the both.</p>
  
  <p>Here under is my code, may be I'm wrong but I do not see where.  Can you help me?</p>
  
  <pre><code>      printuart(14,"SLEEP MODE ON");          
        EINTInit();   
  
        LPC_SC-&gt;PCON &amp;= ~(0x03 &lt;&lt;0); 
  
        flagwakeup=0;
  
        while(flagwakeup==0)
            checkwdt_ev(); //reset watchdog
  
      NVIC_DisableIRQ(EINT1_IRQn);
  
      LPC_PINCON-&gt;PINSEL4 &amp;= ~(0x03 &lt;&lt; 22);   //as gpio
      LPC_GPIO2-&gt;FIODIR &amp;= ~(0x01 &lt;&lt;11);  // as input
      LPC_PINCON-&gt;PINSEL2 &amp;= ~(0x03&lt;&lt;26); // P2.13 as GPIO
      LPC_GPIO2-&gt;FIODIR &amp;=~(1&lt;&lt;13);   //P2.13 as input
  
      printuart(16,"SLEEP MODE OFF");
  
  
  uint32_t EINTInit( void )
  {
   LPC_PINCON-&gt;PINSEL4 &amp;= ~(3UL&lt;&lt;22); // Reset P2.11  to GPIO
   LPC_PINCON-&gt;PINSEL4 |= (0x01&lt;&lt;22); // P2.11 as external interupt
  
   LPC_PINCON-&gt;PINSEL4 &amp;= ~(3UL&lt;&lt;26); // Reset P2.13  to GPIO
   LPC_PINCON-&gt;PINSEL4 |= (0x01&lt;&lt;26); // P2.13 as external interupt
  
   LPC_GPIOINT-&gt;IO2IntEnF = ((0x01 &lt;&lt;11) | (0x01 &lt;&lt;13));   //Port2.11 and P2.13 are  falling edge.
  
  
   LPC_SC-&gt;EXTMODE = (EINT1_EDGE | EINT3_EDGE) ;      //INT1 and INT3 edge trigger
  
   LPC_SC-&gt;EXTPOLAR = 0;              //INT1 and INT3 is falling edge by default
  
  
  
   NVIC_EnableIRQ(EINT1_IRQn);
  
   return( TRUE );
  }
  
  
  
  void EINT1_IRQHandler (void)
  
  {
    LPC_SC-&gt;EXTINT = EINT1;       /* clear interrupt */
  
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;3);      //power on uart0
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;4);      //power on uart1
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;7);      //power on i2c0
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;8);      //power on SPI
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;10);     //power on SSP1
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;19);     //power on i2c1
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;21);     //ppower on SSP0
    LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;26);     //power on i2c2
  
    //test2_count_fhn(15,"SLEEP MODE OFF");
  
    flagwakeup=1;
  
  }
  </code></pre>
  
  <p>I have also try another and I've the same result :</p>
  
  <pre><code>    printuart(14,"SLEEP MODE ON");
  
  
                EINTInit();   //external interrupt for wake up after sleep mode
                EINT3Init();
  
                LPC_SC-&gt;PCON &amp;= ~(0x03 &lt;&lt;0); 
                flagwakeup=0;
  
                while(flagwakeup==0)
                    checkwdt_ev(); //reset watchdog
  
              NVIC_DisableIRQ(EINT1_IRQn);
              NVIC_DisableIRQ(EINT3_IRQn);
              LPC_PINCON-&gt;PINSEL4 &amp;= ~(0x03 &lt;&lt; 22);   //as gpio
              LPC_GPIO2-&gt;FIODIR &amp;= ~(0x01 &lt;&lt;11);  // as input
              LPC_PINCON-&gt;PINSEL2 &amp;= ~(0x03&lt;&lt;26); // P2.13 as GPIO
              LPC_GPIO2-&gt;FIODIR &amp;=~(1&lt;&lt;13);   //P2.13 as input
  
              printuart(16,"SLEEP MODE OFF");
  
  
  
  
      uint32_t EINTInit( void )
  
      {
        LPC_PINCON-&gt;PINSEL4 &amp;= ~(3UL&lt;&lt;22);    // Reset P2.11  to GPIO
        LPC_PINCON-&gt;PINSEL4 |= (0x01&lt;&lt;22);    // P2.11 as external interupt
  
        LPC_GPIOINT-&gt;IO2IntEnF = (0x01 &lt;&lt;11); //Port2.11 is falling edge.
  
  
        LPC_SC-&gt;EXTMODE = EINT1_EDGE ;        // INT1 edge trigger
  
        LPC_SC-&gt;EXTPOLAR = 0;             // INT1 is falling edge by default
  
  
  
        NVIC_EnableIRQ(EINT1_IRQn);
  
        return( TRUE );
  
      }
  
  
      uint32_t EINT3Init( void )
  
      {
        LPC_PINCON-&gt;PINSEL4 &amp;= ~(3UL&lt;&lt;26);    // Reset P2.13  to GPIO
        LPC_PINCON-&gt;PINSEL4 |= (0x01&lt;&lt;26);    // P2.13 as external interupt
  
  
  
  
  
        LPC_GPIOINT-&gt;IO2IntEnF |= (0x01 &lt;&lt;13);    //Port2.13 is falling edge.
  
        LPC_SC-&gt;EXTMODE |= EINT3_EDGE;        // INT3 edge trigger 
  
        LPC_SC-&gt;EXTPOLAR = 0;             //INT1 is falling edge by default */
  
  
  
        NVIC_EnableIRQ(EINT3_IRQn);
  
        return( TRUE );
  
      }
  
  
  
      void EINT3_IRQHandler (void)
  
      {
        LPC_SC-&gt;EXTINT = EINT3;       //clear interrupt 
  
  
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;3);      //power on uart0
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;4);      //power on uart1
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;7);      //power on i2c0
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;8);      //power on SPI
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;10);     //power on SSP1
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;19);     //power on i2c1
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;21);     //ppower on SSP0
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;26);     //power on i2c2
  
  
        flagwakeup=1;
  
      }
  
      void EINT1_IRQHandler (void)
  
      {
        LPC_SC-&gt;EXTINT = EINT1;       //clear interrupt 
  
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;3);      //power on uart0
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;4);      //power on uart1
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;7);      //power on i2c0
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;8);      //power on SPI
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;10);     //power on SSP1
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;19);     //power on i2c1
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;21);     //ppower on SSP0
        LPC_SC-&gt;PCONP |= (0x01 &lt;&lt;26);     //power on i2c2
  
        flagwakeup=1;
  
  }
  </code></pre>
  
  <p>I suppose that my problem is in the init of the interrupt (?)</p>
  
  <p>If someone can help me,</p>
  
  <p>thanks</p>