⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sm__driver_8c.html

📁 使用AVR单片机控制步进电机的软件代码
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>AVR446 - Linear speed control of stepper motor: sm_driver.c File Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div><h1>sm_driver.c File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>Stepper motor driver. <p>Stepper motor driver, increment/decrement the position and outputs the correct signals to stepper motor.<p><ul><li>File: <a class="el" href="sm__driver_8c.html">sm_driver.c</a></li><li>Compiler: IAR EWAAVR 4.11A</li><li>Supported devices: All devices with a 16 bit timer can be used. The example is written for ATmega48</li><li>AppNote: AVR446 - Linear speed control of stepper motor</li></ul><p><dl compact><dt><b>Author:</b></dt><dd>Atmel Corporation: <a href="http://www.atmel.com">http://www.atmel.com</a> <br> Support email: <a href="mailto:avr@atmel.com">avr@atmel.com</a></dd></dl><dl compact><dt><b>Name</b></dt><dd>RELEASE_1_0 </dd></dl><dl compact><dt><b>Revision</b></dt><dd>1.2 </dd></dl><dl compact><dt><b>RCSfile</b></dt><dd><a class="el" href="sm__driver_8c.html">sm_driver.c</a>,v </dd></dl><dl compact><dt><b>Date</b></dt><dd>2006/05/08 12:25:58 </dd></dl><p>Definition in file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.<p><code>#include &lt;ioavr.h&gt;</code><br><code>#include "<a class="el" href="global_8h-source.html">global.h</a>"</code><br><code>#include "<a class="el" href="sm__driver_8h-source.html">sm_driver.h</a>"</code><br><p>Include dependency graph for sm_driver.c:<p><center><img src="sm__driver_8c__incl.png" border="0" usemap="#sm_driver.c_map" alt="Include dependency graph"></center><map name="sm_driver.c_map"><area href="global_8h.html" shape="rect" coords="92,7,162,34" alt=""><area href="sm__driver_8h.html" shape="rect" coords="186,7,276,34" alt=""></map><p><a href="sm__driver_8c-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Defines</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a0">BIT_A1</a>&nbsp;&nbsp;&nbsp;3</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a1">BIT_A2</a>&nbsp;&nbsp;&nbsp;2</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a2">BIT_B1</a>&nbsp;&nbsp;&nbsp;1</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a3">BIT_B2</a>&nbsp;&nbsp;&nbsp;0</td></tr><tr><td colspan=2><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a6">sm_driver_Init_IO</a> (void)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Init of io-pins for stepper motor.  <a href="#a6"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a7">sm_driver_StepCounter</a> (signed char inc)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Move the stepper motor one step.  <a href="#a7"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a8">sm_driver_StepOutput</a> (unsigned char pos)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert the stepcounter value to signals for the stepper motor.  <a href="#a8"></a><br><br></td></tr><tr><td colspan=2><br><h2>Variables</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a5">stepPosition</a> = 0</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Position of stepper motor.  <a href="#a5"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>__flash unsigned char&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="sm__driver_8c.html#a4">steptab</a> []</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Table with control signals for stepper motor.  <a href="#a4"></a><br><br></td></tr></table><hr><h2>Define Documentation</h2><a class="anchor" name="a0" doxytag="sm_driver.c::BIT_A1" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> #define BIT_A1&nbsp;&nbsp;&nbsp;3          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00029">29</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.    </td>  </tr></table><a class="anchor" name="a1" doxytag="sm_driver.c::BIT_A2" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> #define BIT_A2&nbsp;&nbsp;&nbsp;2          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00030">30</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.    </td>  </tr></table><a class="anchor" name="a2" doxytag="sm_driver.c::BIT_B1" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> #define BIT_B1&nbsp;&nbsp;&nbsp;1          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00031">31</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.    </td>  </tr></table><a class="anchor" name="a3" doxytag="sm_driver.c::BIT_B2" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> #define BIT_B2&nbsp;&nbsp;&nbsp;0          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00032">32</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.    </td>  </tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="a6" doxytag="sm_driver.c::sm_driver_Init_IO" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> void sm_driver_Init_IO           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">void&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Init of io-pins for stepper motor. <p><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00049">49</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.<p>References <a class="el" href="sm__driver_8h-source.html#l00043">A1</a>, <a class="el" href="sm__driver_8h-source.html#l00044">A2</a>, <a class="el" href="sm__driver_8h-source.html#l00045">B1</a>, <a class="el" href="sm__driver_8h-source.html#l00046">B2</a>, <a class="el" href="sm__driver_8h-source.html#l00042">SM_DRIVE</a>, and <a class="el" href="sm__driver_8h-source.html#l00041">SM_PORT</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00042">Init()</a>.<p><pre class="fragment"><div>00050 {00051   <span class="comment">// Init of IO pins</span>00052   <a class="code" href="sm__driver_8h.html#a3">SM_PORT</a> &amp;= ~((1&lt;&lt;<a class="code" href="sm__driver_8h.html#a5">A1</a>) | (1&lt;&lt;<a class="code" href="sm__driver_8h.html#a6">A2</a>) | (1&lt;&lt;<a class="code" href="sm__driver_8h.html#a7">B1</a>) | (1&lt;&lt;<a class="code" href="sm__driver_8h.html#a8">B2</a>)); <span class="comment">// Set output pin registers to zero</span>00053   <a class="code" href="sm__driver_8h.html#a4">SM_DRIVE</a> |= ((1&lt;&lt;<a class="code" href="sm__driver_8h.html#a5">A1</a>) | (1&lt;&lt;<a class="code" href="sm__driver_8h.html#a6">A2</a>) | (1&lt;&lt;<a class="code" href="sm__driver_8h.html#a7">B1</a>) | (1&lt;&lt;<a class="code" href="sm__driver_8h.html#a8">B2</a>)); <span class="comment">// Set output pin direction registers to output</span>00054 }</div></pre>    </td>  </tr></table><a class="anchor" name="a7" doxytag="sm_driver.c::sm_driver_StepCounter" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> unsigned char sm_driver_StepCounter           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">signed char&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>inc</em>          </td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -