[go: up one dir, main page]

0% found this document useful (0 votes)
178 views3 pages

External Interrupt in ARM MBED LPC1768 - MBED

This document discusses external interrupts in ARM mbed LPC1768. It introduces interrupts and describes how the ARM mbed has interrupt features on its GPIO pins. It provides examples of using functions like InterruptIn, disable_irq, enable_irq, mode, read, fall, and rise to initialize and attach callbacks to interrupts on specific pins when different interrupt events like rising or falling edges occur. It includes an example program that generates an interrupt on a rising edge detected on GPIO pin P16 and prints a message when triggered.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views3 pages

External Interrupt in ARM MBED LPC1768 - MBED

This document discusses external interrupts in ARM mbed LPC1768. It introduces interrupts and describes how the ARM mbed has interrupt features on its GPIO pins. It provides examples of using functions like InterruptIn, disable_irq, enable_irq, mode, read, fall, and rise to initialize and attach callbacks to interrupts on specific pins when different interrupt events like rising or falling edges occur. It includes an example program that generates an interrupt on a rising edge detected on GPIO pin P16 and prints a message when triggered.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

External Interrupt in ARM MBED LPC1768

Introduction
An interrupt is an event that occurs randomly in the flow of continuity. It is just like a call you have when you are busy with some
work and depending upon call priority you decide whether to attend or neglect it.

ARM MBED has interrupt feature on its GPIO pins. In ARM MBED board pins 5 to 30 can be used as an interrupt input, excepting
only pins 19 and 20.

We can set rising edge, falling edge, both edges, low level, and high level interrupt modes on GPIO pins of MBED board. It will
generate an interrupt when set event (modes) of interrupt occurs.

External Interrupt Functions for MBED


We need to use below functions to initialize interrupt and mode of interrupt for specific GPIO pin.

InterruptIn(pin)

Create an InterruptIn Object to create an interrupt of the specified pin.

pin: provide pin name where you want to connect

Ex.: InterruptIn event(p16);

disable_irq()

To disable interrupt request

Ex.: event.disable_irq();

enable_irq()

To enable interrupt request

Ex.: event.enable_irq();

mode (pull)

To set the input pin mode.

Pull : PullUp, PullDown, PullNone

Ex.: event.mode (PullUp);

read (void)

To read the interrupt pin respected as 0 or 1.

Return:

0 for logic 0 and 1 for logic 1.

Ex.: event.read();

    fall (Callback< void()> func) 

Attach interrupt function request when falling edge is occurred


Ex.: event.fall(&function name);

    rise (Callback< void()> func)

Attach interrupt function request when rising edge is occurred

Ex.: event.rise(&function name);

Example
Let’s write a program which will generate an interrupt when rising edge detected on GPIO (here p16) pin. Here, switch input is used
to interrupt MBED. We will print ‘triggered’ on serial window when interrupt occured.

Interfacing Diagram
 

Fig. interfacing diagram

Program​
// Flash an LED while waiting for events

#include "mbed.h"

InterruptIn event(p16); //create interrupt event object for p16 pin

DigitalOut led(LED1); //create led object for led1

void trigger() {

printf("triggered!\n"); //print triggered! on serial window

int main() {

event.rise(&trigger); //call trigger function when interrupt event is rise

while(1) {

led = !led; //invert led

wait(0.25); //wait for 250ms

You might also like