Answer the question
In order to leave comments, you need to log in
How not to postpone interrupt processing indefinitely?
If I disable the processing of this interrupt in the interrupt code, for example, for a couple of seconds, then the interrupt will indeed not be processed for these two seconds, but if it was, it will be processed immediately after the next interrupt is connected. Do I understand correctly that the microcontroller remembers the fact of the interrupt, and since my vector is the only one for this processing, and it is turned off, it cannot throw off this flag until I just turn on the interrupt again and it immediately joyfully passes it to me? Is there any way to override this behavior? Or throw off this flag in some other way? At some point, I want to completely disable processing, so that if there were interruptions during the absence of the handler (as I understand they always exist), then I don’t need to report them.
volatile bool interrupt;
bool process;
void isr() {
interrupt = true;
digitalWrite(13, HIGH);
delayMicroseconds(10000);
digitalWrite(13, LOW);
}
void setup() {
pinMode(3, INPUT_PULLUP);
attachInterrupt(1, isr, FALLING);
}
void loop() {
if (interrupt) {
detachInterrupt(1);
interrupt = false;
process = true;
}
if (process) {
delay(2000);
process = false;
attachInterrupt(1, isr, FALLING);
}
}
Answer the question
In order to leave comments, you need to log in
If I disable the processing of this very interrupt in the interrupt code, for example, for a couple of seconds, then the interrupt will indeed not be processed for these two seconds, but if it was, it will be processed immediately after the next interrupt is connected.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question