Interrupt Pin

June 2, 2017

Introduction

In system programming, an interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. An interrupt alerts the processor to a high-priority condition requiring the interruption of the current code the processor is executing. The processor responds by suspending its’ current activities, saving its’ state, and executing a function called an interrupt handler (or an interrupt service routine, ISR) to deal with the event. This interruption is temporary, and, after the interrupt handler finishes, the processor resumes normal activities. evive has 6 external interrupt pin:

  • 2 (interrupt 0)
  • 3 (interrupt 1)
  • 18 (interrupt 5)
  • 19 (interrupt 4)
  • 20 (interrupt 3)
  • 21 (interrupt 2)

These pins can be configured to trigger an interrupt on a low level, a rising or falling edge, or a change in level.

How to use Interrupt Pins in Arduino IDE

attachInterrupt()

In the Arduino IDE environment, you can attach interrupts using attachInterrupt() function. There are two different ways you can initialize an interrupt pin:

attachInterrupt(digitalPinToInterrupt(pin), ISR, mode);

attachInterrupt(interrupt, ISR, mode);

where, interrupt is the number of the interrupt pin (from 0-5), pin is the pin number, ISR is the function that you call when interrupt occurs (these functions do not take parameters and returns nothing. This function is also referred to as an interrupt service routine), and mode defines how the interrupt occurs. There are several types of mode listed in the table below:

Trigger TypeTrigger Action
LOWTrigger the interrupt whenever the pin is low
CHANGETrigger the interrupt whenever the pin value changes
RISINGTrigger when the pin goes from low to high
FALLINGTrigger when the pin goes from high to low

Example

detachInterrupt()

To detach an interrupt, you have to u the e detachInterrupt() function in Arduino IDE platform. There are two different ways to do it:

detachInterrupt(interrupt);

detachInterrupt(digitalPinToInterrupt(pin));

Share this Documentation
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Tutorials & Projects
All articles loaded
No more articles to load
Featured Projects
Space-Battle-Game on Scratch

Space Battle

This project will show you how to make a cool space battle game on your own in PictoBlox (Scratch-based programming) and play using your Smartphone!

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart