Can't have delay in the interrupt program.

I want to have a 10min delay after last step in the interrupt program, then return to the main program. Could you give me some advise? Thanks in advance!

When you get into your ISR, set a flag then get out.

In loop() if the flag is set, do your stuff then reset the flag.

BTW, delay() doesn’t work in an ISR.

xiangqian:
I want to have a 10min delay after last step in the interrupt program, then return to the main program.

larryd:
When you get into your ISR, set a flag then get out.

In loop() if the flag is set, do your stuff then reset the flag.

BTW, delay() doesn’t work in an ISR.

When the text codes of @larryd are converted to programming codes, they appear as:

void loop()
{
   if(flag1 == true)
   {
      unsigned long presentMillis = millis();
      while(millis() - presentMillis < 600000UL)    //10*60*1000 in ms; UL = unsigned long = 32-bit
      {
          ;   //do if you have any stuff to doe; else, just wait
      }
      flag1 = false;          //be ready to get 10-min delay next time 
   }
}

vois myISR()
{
   //do your stuff here
   flag1 = true;    //from the flag1's value, the MCU understands that it visited myISR() sub-program
}

Are you sure you need to use an interrupt in the first place?- it often seems like a good idea on the face of it, but turns out to be an unnecessary complication.

larryd:
BTW, delay() doesn’t work in an ISR.

In most cases you can make delay() work in ISR just by invoking sei(). But it's not a good practice in general.

xiangqian:
I want to have a 10min delay after last step in the interrupt program, then return to the main program. Could you give me some advise? Thanks in advance!

If you envisage an Interrupt Service Routine taking longer than 100 microsecs to complete then your basic program design is flawed.

If some time is being measured in minutes it seems unlikely that there is any need to use an interrupt.

...R

Robin2:
If some time is being measured in minutes it seems unlikely that there is any need to use an interrupt.

Unlikely yes, but not impossible.

The thing that triggers the 10 minutes may itself be very fleeting, but of course in the absence of much any info from OP, who knows?

elvon_blunden:
The thing that triggers the 10 minutes may itself be very fleeting,

You are quite correct.

My guess is that this is not one of those occasions - but I have been wrong in the past.

...R

elvon_blunden:
Are you sure you need to use an interrupt in the first place?- it often seems like a good idea on the face of it, but turns out to be an unnecessary complication.

Agreed. If your timebase is in minutes or tens of minutes (ir even seconds), the relative complexity of interrrupts is unnecessary.
They're great, and very useful - in the right place... this may not be it.

lastchancename:
If your timebase is in minutes or tens of minutes (ir even seconds), the relative complexity of interrrupts is unnecessary.

But it depends on how fleeting the thing you're looking for is. Could be a really really short pulse that a poll could miss, regardless of the time between them.

True. Mea culpa.
I should have queried the minimum trigger pulse requirement vs the ‘actual’ ‘polled’ loop period !

Although in Arduino-land that’ more often than not is going to be a (very) short pulse at 16MHz
Also worth mentioning pulse shaping/conditioning and debouncing.