Arduino Forum

Using Arduino => Networking, Protocols, and Devices => Topic started by: Ishmael123 on Feb 24, 2016, 07:48 pm

Title: What type of interrupt is used for the Wire.onReceive function?
Post by: Ishmael123 on Feb 24, 2016, 07:48 pm
Hi, I've been doing a bit of research into how my Arduino uno handles interrupts and it looks like it only has two types available: pinchange and external. External interrupts only work on pins 2 and 3 while a pinchange interrupt will be engaged (to my knowledge) whenever the pin changes state ie a rising or falling edge. But, when interfacing two Arduinos together with I2C I can get the function Wire.onReceive to interrupt my code without using either type of interrupt. How is this achieved?
Title: Re: What type of interrupt is used for the Wire.onReceive function?
Post by: PaulS on Feb 24, 2016, 09:06 pm
There are timer interrupts, too.

Quote
But, when interfacing two Arduinos together with I2C I can get the function Wire.onReceive to interrupt my code without using either type of interrupt.
How do you know that? Obviously, external interrupts aren't used, since the I2C pins are not external interrupt pins.
Title: Re: What type of interrupt is used for the Wire.onReceive function?
Post by: chucktodd on Feb 25, 2016, 01:14 am
Hi, I've been doing a bit of research into how my Arduino uno handles interrupts and it looks like it only has two types available: pinchange and external. External interrupts only work on pins 2 and 3 while a pinchange interrupt will be engaged (to my knowledge) whenever the pin changes state ie a rising or falling edge. But, when interfacing two Arduinos together with I2C I can get the function Wire.onReceive to interrupt my code without using either type of interrupt. How is this achieved?
Read a little deeper in the Atmel datasheet.  Here is a list of the hardware interrupts on the Atmel ATmega328P:

(http://s5.postimg.org/fkajiu9w7/Interrupt_List.jpg)

Only vector 2 and 3 are accessible via AttachInterrupt().  The rest are used in libraries.

If you want an easy way to use the PinChange interrupts check out GreyGnome's EnableInterrupt library (https://github.com/GreyGnome/EnableInterrupt)

Chuck.
Title: Re: What type of interrupt is used for the Wire.onReceive function?
Post by: Ishmael123 on Feb 26, 2016, 05:50 am
Sorry, I was mistaken in my premise. Wire.onReceive is not actually interrupting my code at all I simply made a different mistake in my code. But thank you for the responses!