Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > 73443d16ffe49ffcb4131bf0d8d1b044 > files > 126

avr-libc-docs-1.6.7-2.fc13.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
    <title>avr-libc: &lt;util/delay.h&gt;: Convenience functions for busy-wait delay loops</title>
    <link href="dox.css" rel="stylesheet" type="text/css">
  </head>
<body>
<center>
<table width="80%">
  <tr>
    <td align="left"><a href="http://www.nongnu.org/avr-libc/">AVR Libc Home Page</a></td>
    <td align="center" colspan=4><img src="avrs.png" alt="AVRs" align="middle" border="0"></td>
    <td align="right"><a href="https://savannah.nongnu.org/projects/avr-libc/">AVR Libc Development Pages</a></td>
  </tr>
  <tr>
    <td align="center" width="13%"><a href="index.html">Main Page</a></td>
    <td align="center" width="13%"><a href="pages.html">User Manual</a></td>
    <td align="center" width="13%"><a href="modules.html">Library Reference</a></td>
    <td align="center" width="13%"><a href="FAQ.html">FAQ</a></td>
    <td align="center" width="13%"><a href="globals.html">Alphabetical Index</a></td>
    <td align="center" width="13%"><a href="group__demos.html">Example Projects</a></td>
  </tr>
</table>
</center>
<hr width="80%">
<!-- Generated by Doxygen 1.6.1 -->
<div class="contents">
<h1>&lt;util/delay.h&gt;: Convenience functions for busy-wait delay loops</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__util__delay.html#gad22e7a36b80e2f917324dc43a425e9d3">_delay_ms</a> (double __ms)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__util__delay.html#gab20bfffeacc678cb960944f5519c0c4f">_delay_us</a> (double __us)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<div class="fragment"><pre class="fragment"><span class="preprocessor">    #define F_CPU 1000000UL  // 1 MHz</span>
<span class="preprocessor"></span>    <span class="comment">//#define F_CPU 14.7456E6</span>
<span class="preprocessor">    #include &lt;<a class="code" href="delay_8h.html">util/delay.h</a>&gt;</span>
</pre></div><dl class="note"><dt><b>Note:</b></dt><dd>As an alternative method, it is possible to pass the F_CPU macro down to the compiler from the Makefile. Obviously, in that case, no <code>#define</code> statement should be used.</dd></dl>
<p>The functions in this header file are wrappers around the basic busy-wait functions from &lt;<a class="el" href="delay__basic_8h.html">util/delay_basic.h</a>&gt;. They are meant as convenience functions where actual time values can be specified rather than a number of cycles to wait for. The idea behind is that compile-time constant expressions will be eliminated by compiler optimization so floating-point expressions can be used to calculate the number of delay cycles needed based on the CPU frequency passed by the macro F_CPU.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>In order for these functions to work as intended, compiler optimizations <em>must</em> be enabled, and the delay time <em>must</em> be an expression that is a known constant at compile-time. If these requirements are not met, the resulting delay will be much longer (and basically unpredictable), and applications that otherwise do not use floating-point calculations will experience severe code bloat by the floating-point library routines linked into the application.</dd></dl>
<p>The functions available allow the specification of microsecond, and millisecond delays directly, using the application-supplied macro F_CPU as the CPU clock frequency (in Hertz). </p>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gad22e7a36b80e2f917324dc43a425e9d3"></a><!-- doxytag: member="delay.h::_delay_ms" ref="gad22e7a36b80e2f917324dc43a425e9d3" args="(double __ms)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void _delay_ms </td>
          <td>(</td>
          <td class="paramtype">double&nbsp;</td>
          <td class="paramname"> <em>__ms</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Perform a delay of <code>__ms</code> milliseconds, using <a class="el" href="group__util__delay__basic.html#ga74a94fec42bac9f1ff31fd443d419a6a">_delay_loop_2()</a>.</p>
<p>The macro F_CPU is supposed to be defined to a constant defining the CPU clock frequency (in Hertz).</p>
<p>The maximal possible delay is 262.14 ms / F_CPU in MHz.</p>
<p>When the user request delay which exceed the maximum possible one, <a class="el" href="group__util__delay.html#gad22e7a36b80e2f917324dc43a425e9d3">_delay_ms()</a> provides a decreased resolution functionality. In this mode <a class="el" href="group__util__delay.html#gad22e7a36b80e2f917324dc43a425e9d3">_delay_ms()</a> will work with a resolution of 1/10 ms, providing delays up to 6.5535 seconds (independent from CPU frequency). The user will not be informed about decreased resolution. </p>

</div>
</div>
<a class="anchor" id="gab20bfffeacc678cb960944f5519c0c4f"></a><!-- doxytag: member="delay.h::_delay_us" ref="gab20bfffeacc678cb960944f5519c0c4f" args="(double __us)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void _delay_us </td>
          <td>(</td>
          <td class="paramtype">double&nbsp;</td>
          <td class="paramname"> <em>__us</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Perform a delay of <code>__us</code> microseconds, using <a class="el" href="group__util__delay__basic.html#ga4e3957917c4c447d0f9166dac881b4e3">_delay_loop_1()</a>.</p>
<p>The macro F_CPU is supposed to be defined to a constant defining the CPU clock frequency (in Hertz).</p>
<p>The maximal possible delay is 768 us / F_CPU in MHz.</p>
<p>If the user requests a delay greater than the maximal possible one, <a class="el" href="group__util__delay.html#gab20bfffeacc678cb960944f5519c0c4f">_delay_us()</a> will automatically call <a class="el" href="group__util__delay.html#gad22e7a36b80e2f917324dc43a425e9d3">_delay_ms()</a> instead. The user will not be informed about this case. </p>

</div>
</div>
</div>

<hr width="80%">
<p><center>Automatically generated by Doxygen 1.6.1 on 30 Nov 2009.</center></p>

</body>
</html>