lpcware

LPC1313 GPIO interrupt

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Michael06433 on Mon Jun 22 08:20:00 MST 2015
Hi there,

I have a problem with the external interrupt on pin 1.8.

The interrupt should be fire when a negative edge is detect.
I connected a LED on P0.3 and my Oszilloscope. The problem is that not every negative edge toggles the P0.3.
Sometimes 3 or 4 times P0.3 toggle than 5 till 7 times it doesn't work.

Has anyone a idea?
Oh, I use a LPC1313/01


void gpio_Init(void)
{

/* Enable AHB clock to the GPIO domain. */
LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 16);  /* enable clock for IOCON      */
LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 6);  /* enable clock for GPIO      */

  // Toggle dir
  LPC_GPIO1->DIR &= ~(1 << 8);//P1.8 Input
  LPC_GPIO0->DIR |= (1<<3); //P0.3 Output

  //Pullup P1.8
  LPC_IOCON->PIO1_8 &= ~((unsigned int) 0x00000018);
  LPC_IOCON->PIO1_8 |= ((unsigned int) 0x00000030);


LPC_GPIO1->IS &= ~(0x1<<8); //sense = Edge
LPC_GPIO1->IBE &= ~(0x1<<8);//single Edge
LPC_GPIO1->IEV &= ~(0x1<<8); //aktive Low
LPC_GPIO1->IE |= (0x1<<8); //interrupt enable
NVIC_SetPriority(EINT1_IRQn,3);
  /* Set up NVIC when I/O pins are configured as external interrupts. */
  NVIC_EnableIRQ(EINT1_IRQn);

}

void PIOINT1_IRQHandler(void)
{
if(LPC_GPIO1->RIS & (0x1<<8))
        {
                if(!y)
        {
      LPC_GPIO0->DATA &= ~0x0008;
         y++;
        }
        else
        {
       LPC_GPIO0->DATA |= 0x0008;
       y=0;
        }
LPC_GPIO1->IC |= (0x1<<8);
__NOP();
__NOP();
        }
}

Outcomes