Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: delay() Question

  1. #1
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    110

    delay() Question

    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

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,572
    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();
        }
    }

  3. #3
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    110
    So..... i see nothing that couldnt be interrupted? I need more coffee....

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,572
    Yes, delay() can be interrupted anytime.

  5. #5
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    110
    Cool. Thank you - presumably i was worried because of bad PicAxe experiences years ago.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •