Closed
Description
I am experiencing a strange bug:
Whenever i use analogRead(), an unrelated interrupt will also trigger, and by changing around a little i could even get 2 interrupts to trigger with every analogRead().
I have not testet every analog pin, but so far this bug happens with A0, A3, A4, A5, A6, A7, but not A10, A11, A12, A13, A14.
I can reproduce the issue with the code below - every 2 seconds it will trigger AnalogRead() and this will trigger one of the button Interrupts. I have have multiple components hooked up as well, but this did not seem to change anything when i tried removing some of them, or having the button GPIOs unconnected.
const int BUTTON_1 = 25;
const int BUTTON_2 = 26;
void setup()
{
pinMode(BUTTON_1, INPUT_PULLUP);
pinMode(BUTTON_2, INPUT_PULLUP);
attachInterrupt(BUTTON_1, int1, FALLING);
attachInterrupt(BUTTON_2, int2, FALLING);
Serial.begin(115200);
}
void loop()
{
delay(2000);
float derp = analogRead(A3);
Serial.println(derp);
}
void int1()
{
Serial.println("1 Interrupt triggered");
}
void int2()
{
Serial.println("2 Interrupt triggered");
}
Metadata
Metadata
Assignees
Labels
Relates to peripheral's APIs.Relates to peripheral's APIs.Common questions & problemsCommon questions & problems