Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Great, thank you! I had always thought that timers were not working in interrupts and that this is why you cannot use delay() there, am I wrong? Commented Dec 11, 2017 at 14:29
  • Sorry, now I may understand: actually, the problem is not that timers were stopped in interrupts, but that delay() relies on an interrupt itself; is this right? Commented Dec 11, 2017 at 14:31
  • Mmh, no, this is not it: delay does not seem to have rely on any interrupt: void delay(unsigned long ms) { uint32_t start = micros(); while (ms > 0) { yield(); while ( ms > 0 && (micros() - start) >= 1000) { ms--; start += 1000; } } } Commented Dec 11, 2017 at 14:34
  • @Zorglub29: delay() relies on micros() which relies on timer0_overflow_count which is updated by the TIMER0_OVF interrupt. Commented Dec 11, 2017 at 16:39