We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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--); }
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.