Interrupt Handling using Arduino Mega

I have attached an interrupt to pin 19 on Arduino Mega.

One of the main issues is that there's a false interrupt trigger
In order to resolve this, I placed a pull down resistor

Despite placing a pull down resistor, the interrupt on pin 19 was triggered so I tried to prevent it with the following code

if(interrupt)
{
  interrupt = 0;
  delay(100);
  x  = digitalRead (19);
  if(x ==1)
  { 
     x = 0;
     interrupt_function();
   }
}

So what the above code does is it checks after 100ms if the digital pin 19 is still high, if so only then interrupt_function() would get executed. On implementing the above code i successfully prevented entering the interrupt function on a false interrupt trigger but the main problem arises on how to resume to the my original function

  1. All i know is the instruction pointer holds the address of the next instruction to be executed. So how do I access it in order to resume from where the controller left off?
    Or is there any other in order to resume to place where the controller left off
  2. How do I prevent the false interrupt trigger at a hardware level in the first place?

Post ALL the code.

What is the source of the interrupt?

Interrupt handlers return to where they were called from. If the the code snippet you posted is in the loop() function then the ISR has already executed and returned to the instruction after it interrupted and continued executing loop(). Therefore, I'm not sure what you are getting at.

To really help we need to see all of your code and understand what device is connected to pin 19.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.