Go Down

Topic: What type of interrupt is used for the Wire.onReceive function? (Read 998 times) previous topic - next topic

Ishmael123

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?

PaulS

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.
The art of getting good answers lies in asking good questions.

chucktodd

#2
Feb 25, 2016, 01:14 am Last Edit: Feb 25, 2016, 01:15 am by chucktodd Reason: vector numbers!
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:



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

Chuck.
Currently built mega http server, Now converting it to ESP32.

Ishmael123

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!

Go Up