I am a beginner with Arduino NANO and this is something I've been trying to figure out for a few hours now. Say, in setup(), I have the following snippet of code:
pinMode(2, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(2), do_this, RISING); pinMode(3, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(3), do_that, RISING);
and there are two ISR functions do_this() and do_that() that are called when two push-button switches are pressed. I understand how the program is supposed to behave when the switches are pushed and released separately. But, what if the RISING action happens, hypothetically, at the same point in time? (Actually, if digital pin 2 and 3 are connected to the same push-button then the 'stimulus', so to speak, will occur at the exact same moment). Which one of the ISRs, if any, will take precedence in this case? I have checked the ATMega328 datasheet, but have not been able to come up with anything satisfactory.
Thanks in advance :)
Edit: Thanks for the detailed insights. I understand that the ISRs have priorities and even if the change is triggered at the same time, the ISRs will be executed one after another depending according to the said priority.
As for the push-button part of the question, I came to the conclusion that when the two interrupt pins are connected together through the push-button, pressing the switch does not trigger any change because one of the External Interrupt Flags gets cleared by the other. I know that's a rough conclusion and I am probably missing a lot of technical nuances but is that idea at least correct? Many thanks