Arduino Leonardo – Interrupts

As of Arduino 1.0, interrupts are not supported on the Arduino Leonardo. I’m working on a project using the atmega32u4 with the Arduino IDE which needs interrupt support for both software serial and frequency counting, so I investigated ways to add interrupt support for this device. I began by checking out the Leonardo pins definition file to see what was missing for interrupt support. Long story short, I ended up copying the macros for interrupt bitmasks/registers from the Teensyduino project, which has a mega32u4 target board. In addition to modifying the pin definition header file, I also needed to modify WInterrupts.c—swapping out the default AttachInterrupt() and DetachInterrupt() funcitons with those from the Teensyduino project.

I have included links below to the pin definition header file and interrupt functions in my project repository. Place these files in the hardware/arduino/core and hardware/arduino/variants/leonardo folders. Note that my current revision of these files only support the m32u4, interrupt support for other devices is broken. You can throw some #ifdefs in there and include the existing code to support devices other than the m32u4, I will hopefully get around to adding this in the coming weeks.

I also want to get SoftwareSerial up and running on the m32u4; I’ll be looking into the Teensyduino variant of NewSoftSerial this week, check back for more updates in the coming days.

Update: The Arduino team has successfully implemented interrupts.

Downloads

Ethan is a computer engineer and open source hardware/software developer from Michigan. He enjoys AVR and linux development, photography, mountain biking, and drinking significant amounts of home-roasted coffee. Find out more at ethanzonca.com.

Tagged with: , ,
Posted in Arduino, Projects
4 comments on “Arduino Leonardo – Interrupts
  1. Jamil Merali says:

    Hi,
    Is there any update or ETA for softwareserial with the Leonardo? Thanks.

  2. Jonathan says:

    Can interrupt support be added to Sparkfun’s Pro Micro? I haven’t had much success trying to use your WInterrupts.c and pins_arduino.h files with the Pro Micro. It at first kept telling me the CORE_INTx_PIN were undefined which I think I had fixed by changing it to EXTERNAL_INT_x. Even still, it was acting intermittenly. Any thoughts?

  3. Sander says:

    links dont work, alas

1 Pings/Trackbacks for "Arduino Leonardo – Interrupts"
  1. […] Interrupts [link] As of Arduino 1.0, interrupts are not supported on the Arduino Leonardo…Long story short, I […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*