The external interrupt input of the LPC1768 is a very important functionality of a software. It is one of the many functions of the system control block that are not related to a specific peripheral device. There are four pins that can be set to function as an external interrupt input (EINTn where n is 0-3). We will be learning how to initialize these pins in the external interrupt input mode and perform an LED switching routine.


  • PIN SELECTION: The four pins that are used for the external interrupt purpose is located from P2.10 to P2.13 and performs this functionality when the corresponding pins in the PINSEL4 register are set as 01.
  • MODE: The external interrupt mode register is a 32-bit register that is used to select the level or edge sensitivity of the respective external interrupt pins.
  • POLARITY: Based on level or edge sensitivity, setting the corresponding bits in the polarity register assumes different roles. In level sensitivity mode, the polarity register decides whether the pin is active high or active low. If the mode is edge sensitive, it decides whether the pin should be sensitive to the rising or falling edge.


  • DEFINITIONS: The definitions that will be used in this program are given below.

  • PIN SELECTION: We will be using external interrupt 0 for this tutorial.

  • MODE: The mode of working that we are going to use is edge triggered external interrupt.

  • POLARITY: The polarity for the edge-triggered mode that we are using is the falling edge.

  • Finally, we must enable the interrupt control using the non vectored interrupt control function setting the EINT0_IRQn as the parameter for the function. The interrupt handler is called when an interrupt occurs and the LED control is set within the interrupt handler function. We will be using the 16th pin of PORT0 to toggle the led between the interrupts.
    NOTE: An important point to note is that the external interrupt flag for the corresponding interrupt pin must be cleared during the interrupt handler function.


    We have learned to program a simple code to set up an external interrupt input and handle a pre-defined task. The sample code for this tutorial is available in the Code Library under the section ARM.

Liked this article! You'll love our video courses.
Checkout our comprehensive pre-recorded Video Courses for ARM Cortex Microcontrollers
More details
Free Embedded C course with this course for a short period of time
Spread the love, share this