0
\$\begingroup\$

I am working on GPIO external interrupt on LPC1769 board and having problems getting it to work. I have connected pin 2.11 to a push button and interrupt must be generated when the button is pushed. Any help is greatly appreciated. Thanks.. Below is the code,

#define EINT0      0
void EINT0_IRQHandler(void)
{
  LPC_GPIOINT->IO2IntClr = (1 << 11);
  printf("0interrupt\n");
}
int main(void) {

LPC_PINCON->PINSEL4 &= ~(3<<20);
LPC_PINCON->PINSEL4 |= (1<<20);

LPC_GPIO2->FIODIR &= ~(1<<10);
// LPC_GPIOINT->IO2IntEnF |= (0x01 <<10);
LPC_SC->EXTMODE = (1<<EINT0);

LPC_SC->EXTPOLAR = (1<<EINT0);


NVIC_EnableIRQ(EINT0_IRQn);

while(1)
{

}
return 0 ;
\$\endgroup\$
2
  • \$\begingroup\$ Is the problem that it won't compile, because this: NVIC_EnableIRQ(EINT0_IRQn); looks like it should be something more like NVIC_EnableIRQ(EINT0_IRQHandler);... Can you define what "having problems" means? \$\endgroup\$
    – Ron Beyer
    Oct 20, 2017 at 3:29
  • \$\begingroup\$ The NVIC_EnableIRQ(EINT0_IRQn); line is correct for most LPC17xx CMSIS versions. Be sure to include the correct header file. \$\endgroup\$
    – Turbo J
    Mar 28, 2018 at 14:55

1 Answer 1

1
\$\begingroup\$

Your Interrupt handler is wrong, it should look like:

void EINT0_IRQHandler(void)
{
  LPC_SC->EXTINT = (1<<EINT0);
  //light LED here, do not try to use printf() inside interrupts
}

But the real culprit might be the GPIO pin 2.10 - which is also used to trigger the UART bootloader on startup when LOW. See in manual UM10360.pdf, chapter 32, describing ISP function.

I recommend using external Interrupt 1 on P2.11 instead, which does not have this restriction.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.