External Interrupt Control in ARM LPC1768

///External Interrupt Control in ARM LPC1768

External Interrupt Control in ARM LPC1768

Introduction

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.

Configuration

  • 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.

Firmware

  • 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.

    Summary

    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.

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
Spread the love, share this

2 Comments

  1. Nik May 20, 2018 at 3:49 pm

    Can you explain why in definition you used 20 22 for external interrupt while their pin are 2.10 and 2.11 ?? I’m so confused with this can you reply me fast

    • OpenLabPro May 28, 2018 at 3:07 pm

      Hi,
      20, 22, 24 and 26 are register values for enabling interrupts.

Leave A Comment

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
close-link
25% OFF - OpenLabPro Course
Use Coupon: CRS25UL

 
ARM Microcontroller Primer
Want to learn indepth programming, peripheral interfacing and driver development?
close-link
Launched: IoT online Course - 25% Off when you complete your order today.
Checkout Now
close-image

Subscribe To our Email Newsletter

Be the first to get latest updates and exclusive content straight to your email inbox.
Send me Tutorials and Guides
close-link