Page 1 of 1

conflict with attachInterrupt

Posted: Tue Mar 17, 2015 1:28 am
by cyborg5
I maintain a library of code called IRLib which receives, decodes, and sends infrared signals. One of the objects in the library makes use of the standard arduino function "attachInterrupt". When I compile a sketch with my library and V-USB I get a linking conflict with INT0_vect. This occurs even if there is no instance of an object containing this function call. My library provides a variety of ways to receive signals some of which make use of "attachInterrupt" and some do not. So even if I'm not using those particular methods where the objects containing those methods, even if I only use objects and methods that do not make use of the built in interrupt handling, they still get linkage errors.

Is there something unique about using INT0_vect that V-USB has to use it? I know that the timing is really critical in your library. I know you can't disable interrupts for very long messes things up. If you guys used some other interest method would be compatible with Arduino's standard attachInterrupt? I would think other users might have a similar conflict that could not be coded around.

Meanwhile they can set up a conditional compile on my library that would force the user to use parts of my library that were not in conflict. But I thought you guys might want to be aware of the situation perhaps in future versions you could have a workaround.

Re: conflict with attachInterrupt

Posted: Tue Mar 17, 2015 10:43 am
by blargg
INT0 is used to give it highest priority. You could probably rewire USB to use INT1 without problem (and make the appropriate change to usbconfig.h), since interrupts are disabled during USB activity. Even when USB uses INT0, you generally have to make the other interrupt handlers non-blocking with ISR_NOBLOCK, otherwise they'll keep interrupts disabled for too long.

Re: conflict with attachInterrupt

Posted: Tue May 05, 2015 3:06 am
by runfifa123
This occurs even if there is no instance of an object containing this function call. My library provides a variety of ways to receive signals some of which make use of "attachInterrupt" and some do not. So even if I'm not using those particular methods where the objects containing those methods, even if I only use objects and methods that do not make use of the built in interrupt handling, they still get linkage errors.