Open brycecherry75 opened 3 years ago
any interrupt which occurs during execution of delay() will be serviced only when delay() has finished executing,
I don't think that's correct, AFAIU delay does not block interrupts for its entire duration (at least not on AVR or SAMD, maybe some 3rd party core does)? It is the case that if an interrupt happens at exactly the right moment, the delay might be a little longer than requested (but that holds even more for the timerless delayMicroseconds()
.
I noted that the standard delay() function is dependent on a timer and its corresponding interrupt on most Arduino microcontrollers and therefore, any interrupt which occurs during execution of delay() will be serviced only when delay() has finished executing, so can I recommend implementing delayTimerless() which is not dependent on a timer and its corresponding interrupt noting a few cautions regarding inaccuracy?
void delayTimerless(word value) { for (word i = 0; i < value; i++) { delayMicroseconds(1000); } }