This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why and when to use Static Function

Dear friend,
can anybody explain me
why this kind of Static function used and when it should be used?

static void delay (unsigned long cnt)
{ while (cnt--);
}

Parents
  • The second part of the question:
    You should almost never perform a delay by busy-looping a fixed number of iterations. The compiler may completely optimize away the loop, since it doesn't have any side effect.

    Configure a timer and either busy-loop reading the timer register, or (for longer delays) configure the timer to generate an interrupt.

Reply
  • The second part of the question:
    You should almost never perform a delay by busy-looping a fixed number of iterations. The compiler may completely optimize away the loop, since it doesn't have any side effect.

    Configure a timer and either busy-loop reading the timer register, or (for longer delays) configure the timer to generate an interrupt.

Children
No data