delay() Question

fdaniels

Well-known member
Moin!

I have some timig critical things to do and need to know if delay() interrupted by an interrupt while its delaying.....

Many thanks for any input,
Frank
 
Hi Frank, I think this answers your question:
Code:
void delay(uint32_t msec)
{
    uint32_t start;

    if (msec == 0) return;
    start = micros();
    while (1) {
        while ((micros() - start) >= 1000) {
            if (--msec == 0) return;
            start += 1000;
        }
        yield();
    }
}
 
Back
Top