title: How to create a delay function in Keil uVision?
body: <p>Arduino has a <code>delay(ms)</code> function to pause the program for a certain amount of time. It is very accurate in milliseconds.</p>
  <p>I have a delay function in C used in Keil uVision for the AT89C5131 microcontroller:</p>
  <pre><code>void delay( unsigned long duration)
  {
      while ( ( duration -- )!= 0);
  }
  </code></pre>
  <p>This does some delay job but the long value is not accurate like Arduino.</p>
  <p>Is there a way to create a function that works like <code>delay()</code> function in Arduino?</p>
  <p>The crystal is running at 24Mhz.</p>