Skip to content
Mike Schwager edited this page Oct 19, 2015 · 17 revisions

Table of Contents

Welcome to the EnableInterrupt wiki!

The EnableInterrupt library is a new Arduino interrupt library, designed for all versions of the Arduino- at this writing, the Uno (and other ATmega328p-based boards, like the mini), Leonardo (and other ATmega32u4-based boards, like the Micro), the Mega2560 (and other ATmega2560-based boards, like the MegaADK), and the SAM cpu based boards Due and Zero (see the Usage wiki page for information on these). Also with limited support are the non-Arduino 644/1284 processor, based on the Mighty 1284 project and files (see https://github.com/maniacbug/mighty-1284p) and the ATtiny 44/84 and 45/85 processors (based on DA Mellis' work at https://github.com/damellis/attiny, but the library should work with the Gemma too).

The library enables you to assign an interrupt to pins on your chip that support them, and presents a common interface to all supported chips. This means that on the Arduino Uno and Mega you don't give it an interrupt number, as per attachInterrupt. Rather, your first argument is the pin number *of a pin that's supported on that chip* (see the bestiary on the Usage wiki page).

See the Installation and Usage wiki pages for information on how to use the library. See the Download page to download the library, or simply go to bintray here.

See more details below. See the examples subdirectory in the distribution for examples of the library in action. Make sure to read the FAQ page as well.

Make sure to read the Important: Interrupt Types wiki page.

IMPORTANT NOTE: In version 0.9.2 I discovered a rather pernicious bug, wherein the library was setting the global interrupt enable bit. This could cause a serious and difficult-to-debug race condition, as it is not the job of the library to manage that bit. The chips come with interrupts enabled so existing code should not be affected, but if you were relying on that behavior note that it has changed. My thanks to http://gammon.com.au/interrupts (the 'How are interrupts queued?' section).

CAUTION: As we are dealing with an embedded processor with a small amount of memory, little error-checking is performed (such as checking to ensure that you are using a supported pin). Caveat Programmer.

Interrupts

Description

What are Interrupts? For a tutorial, see http://www.engblaze.com/we-interrupt-this-program-to-bring-you-a-tutorial-on-arduino-interrupts/ The posting gets into low-level details on interrupts. Take it slow and bit by bit you will understand. In short, interrupts are designed to handle something that needs to take place right now, no matter what your main program is doing at the moment. If this sounds like something your sketch needs to do then you're in the right place.

What do interrupts do, technically? They listen to a signal on a digital pin, and they make your sketch stop what it's doing. Almost immediately they run a subroutine that you created called an Interrupt Sub-Routine, or ISR. So for example if your sketch needs to know when someone pushes a button that changes a pin's voltage from HIGH to LOW, then you'll want to create an interrupt that calls your subroutine based on a FALLING signal. If the button makes the signal go from LOW to HIGH, then you'll want to call a subroutine based on a RISING signal. If you want to know both, then you're interested in a CHANGE of signal.

Available Pins

On many of the Arduino boards only a certain number of pins support interrupts. For a list, see the wiki Usage page, the bestiary section.

How Do I Use It?

There are more details to be learned about interrupts, but those are the bare essentials. With the above background information you are ready to get started and utilize interrupts in a sketch.

See the Usage wiki page for the details of how to use library.

LICENSE

Licensed under the Apache2.0 license. See the source files for the license boilerplate, the LICENSE file for the full text, and the NOTICE file which is required by the Apache2.0 license to be distributed with any code that you distribute that uses this library. The copyright holder for this code is Michael Schwager.

Survey

I conducted a survey prior to publishing this library. The purpose was to determine if a library like this would be considered useful to anyone besides me. See the results here: https://www.surveymonkey.com/results/SM-W9HYWH57/

Clone this wiki locally