I have a problem with Interrupts in arduino Yun.
As I understand: after interrupt (interrupt is performed when it detects a rising edge) processor should continue the main program but in my case it is not.
When I press the button interrupt is executed and program "hangs" in this interruption, does not return to the loop ().Only after releasing the button, program is return to main loop().
My code looks something like this:
volatile int count = 0;
void setup()
{
attachInterrupt(0, inc, RISING);
}
void loop()
{
// Here a few functions that should be performed cyclic
}
void inc() //interrupt function
{
count = count + 1; //variable is incremented and the program "hangs"
// at this point, does not return to the loop ();
//until I release the button
}
I would ask for help / explanation of why this can happen.
Program is large.
Supports: display, rtc, keyboard and telnet, and a few other things.
The new project actually works.
Is there a possibility that one of the libraries uses the interrupt and breaks something?
Of course, I don't use delay ();
Interrupt routines must be shorter as possible and no complex code has to be executed inside an interrupt function. Inside an interrupt you can't listen for another interrupts and the Wire class rely on interrupts.
So if you use the Wire library inside an interrupt it wont work.
You say execution doesn't return until the button is released. How many times does the counter get incremented?
While you are configuring rising edge interrupts, it almost seems like it's getting switched to level sensitive interrupts: this would mean that the interrupt service routine would keep re-entering over and over as long as the input is active. The side effect of this is that the counter would be incremented MANY times, hence my initial question.