AVR (& Arduino) Default ISR – Resetting Pin Change Interrupt Problem

I just got done wasting 10 very frustrating hours on a Interrupt Service Routine problem.  In this case it was a pin change interrupt that causes the chip/board to reset.  It turned out to be a simple capitalization error but luckily I also discovered some info about the AVR default ISR.  I wanted to post it here in case somebody accidentally found it useful.  

I was using a pin change interrupt on a custom board I’d made (ATMEGA328P acting as an Arduino Uno).  I read everything I could find and thought I had everything set up but noticed that every time my ISR should have triggered, the board reset instead.

I checked everything until I was re-reading an ATMEL support document and realized that if you have enabled interrupts on a specific pin and an interrupt occurs and you do not have an ISR defined for that interrupt, the chip will execute the default ISR which in most cases activates the reset ISR and the board resets.

The first thing to note is that you can write your own default ISR if you don’t want this to happen.  Just make sure you #include <avr/interrupt.h> and then create a function:

// code to execute here

This allowed me to realize that I had mis-capitalized the pin change ISR I wrote, which is why I thought it existed but the chip didn’t.  Below are the correct and incorrect versions.  See if you can find the difference.

// Incorrect Version
// Correct Version



5 thoughts on “AVR (& Arduino) Default ISR – Resetting Pin Change Interrupt Problem

  1. I am coming back to microprocessors after a long hiatu. It was in early eighties when I programmed micros, it is a Funtime for all the young guys. It is very rewarding to learn on very powerful and flexible boards now. I so glad to have found your website. I just learnt some very useful and at the same time very powerful methods of pin change interrupt routine assignments procedure. I looked many places before I found these pages, needles to say, you are doing a great job and serving the growing community of micro-players very well. I raise pigeons and dogs and that is what brought me back to electronics. First, I need a precisely time-ontrolled feeder for my animals so I can take vacations without having to ask others to help and secondly, I need a precise heated nest bowl to induce cutaneous water evaporation mechanism so they can flying in very high temperature in hot summers of Arizona. So, here I am at the age of sixty back on the soldering bench. There are many projects in the books that relate to biological manipulation of birds to improve their ability to sustain their survival in hot climate. You are doing a great job and I hope that you continue your efforts. Regards, Felix

  2. Thank you soooooo much. I’ve been tearing out my hair for hours. Another problem I encountered is the interrupt vector is (on Atmega328p) ISR(PCINT0_vect) is used for PCINT 0-7 , ISR(PCINT1_vect) is used for PCINT 8-14, and ISR(PCINT2_vect) is used for 16-23.
    The names were extremely misleading and turned out to be the source of my problems.
    The information you had here helped me to locate my problem. Again Thank You, I’ve been searching the internet for hours before I found this website and I had nearly given up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s