lpcware

Using: LPC11U14  setting up an external interrup not working

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by ticup on Wed May 23 13:32:42 MST 2012
Hi there, down below is the code that I wrote to set up an external interrupt; I could build and transfer the code to LPC11U14. I have a switch between PIO1_29 and ground. I press on the switch and I expect to print in the trace window some text. I get nothing. Could someone have a look at my code and help me to understand where I am wrong...??? thanks

/*
===============================================================================
Name        : main.c
Author      :
Version     :
Copyright   : Copyright (C)
Description : main definition
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC11Uxx.h"
#endif

#include "cr_section_macros.h"
#include "NXP/crp.h"

//#include "lpc11uxx_pinsel.h"
//#include "stdio.h"
//#include "gpio.h"

#include "lpc_types.h"
#include "lpc11uxx_gpio.h"
#include "LPC11Uxx.h"
#include "lpc11uxx_pinsel.h"
#include "string.h"
#include "stdio.h"


// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;


void FLEX_INT0_IRQHandler(void)
{
    printf("FLEX_irq handler kicked");
    NVIC_ClearPendingIRQ(FLEX_INT0_IRQn);
}

int main(void) {

   // TODO: insert code here
   volatile static int i = 0 ;
   LPC_GPIO_PIN_INT->ISEL &= ~(0x1<<LPC_IOCON->PIO1_29);/* Edge trigger */
   LPC_GPIO_PIN_INT->IENF |= (0x1<<LPC_IOCON->PIO1_29); );/* falling edge */
   LPC_SYSCON->PINTSEL[0] = LPC_IOCON->PIO1_29; //here we assign the port 1 pin 29 to ext. interrupt 0
   LPC_IOCON->PIO1_29 = PINSEL_FUNC_0;  //default is the general IO
  
   NVIC_SetPriority(FLEX_INT0_IRQn,0);   /* Default priority can be 0(highest) - 31(lowest) */
   NVIC_EnableIRQ(FLEX_INT0_IRQn);       /* Enable External Interrupt 0 Interrupt */
  
// Enter an infinite loop, just incrementing a counter
    while(1) {

i++ ;
   }
   return 0 ;
}

Thanks for the help....!!

Outcomes