Can I disable the interrupts inside the interrupt handling function(ISR)? Do I have to do with cli() or can I use Timer1.detachInterrupt()?
I read on the main wiki that delay function dosen't work inside the ISR function, I suppose this is still true also inside sub functions called from ISR function, is that true?
hi,
What you should try to do is set a flag inside the isr which you then check in loop - but if your application is critically time sensitive there are other approaches using the timer itself i.e. Simply add your delay period to one of the output compare registers and exit the isr. When your delay period has passed the isr will be called and you can do whatever it is that you wanted to do.
More than "not reliable" it will lock up the processor I believe. Think of what an interrupt routine does - it takes over the processor and stops everything else from happening - so you can only wait for external changes usefully - and in general you shouldn't take any more CPU cycles than is absolutely necessary. Typically an interrupt routine's job is to buffer some input or progress some output, and setting flags to communicate readiness for the next operation. ISR talks to the hardware, main program talks to the ISR...