Interrupts and the delay function

Hi there,

Sorry if this has been asked already, but I did a search and couldn't find an answer to my question. In my code, I have an interrupt that fires at a rate of 8kHz. However, in the 'loop()' function, I want to execute a command approximately every second. Will using 'delay(1000)' work properly, or will having interrupts add some extra delay to my delay(1000)? My initial tests seem to indicate that delay is working properly even with interrupts, but I want to be sure on this.

Thanks a lot!

delay() uses millis(), so delays introduced by interrupts will only accumulate if your interrupts are long enough to cause some millis() interrupts to be missed. How much time does your ISR take?

If you use a loop delay, interrupts will make it longer, but usually interrupts are so short compared with the frequency with which they occur that this lengthening can be ignored. Divide the length of your interrupt by the period of the interrupt cycle and this is the percentage by which a loop delay will be lengthened.

  • Ben