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

📄 main_8c.html

📁 一个用GCC做的atmel芯片控制的无刷无传感器的程序.包括各种参考文档!
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00781"></a>00781     }<a name="l00782"></a>00782   }<a name="l00783"></a>00783 <a name="l00784"></a>00784   <span class="keywordflow">if</span> (current &gt; <a class="code" href="BLDC_8h.html#a72">CURRENT_LIMITER_START</a>)<a name="l00785"></a>00785   {<a name="l00786"></a>00786     overCurrentCorrection = (current - <a class="code" href="BLDC_8h.html#a72">CURRENT_LIMITER_START</a>) * <a class="code" href="BLDC_8h.html#a75">CURRENT_LIMITER_FACTOR</a>;<a name="l00787"></a>00787   }<a name="l00788"></a>00788 <a name="l00789"></a>00789   <span class="keywordflow">if</span> (overCurrentCorrection &gt; 255)<a name="l00790"></a>00790   {<a name="l00791"></a>00791     <span class="keywordflow">return</span> 255;<a name="l00792"></a>00792   }<a name="l00793"></a>00793 <a name="l00794"></a>00794   <span class="keywordflow">return</span> overCurrentCorrection;<a name="l00795"></a>00795 }</pre></div><p><p>Here is the call graph for this function:<p><center><img src="main_8c_a33_cgraph.png" border="0" usemap="#main_8c_a33_cgraph_map" alt=""></center><map name="main_8c_a33_cgraph_map"><area href="BLDC_8h.html#a98" shape="rect" coords="164,7,287,33" alt=""></map>    </td>  </tr></table><a class="anchor" name="a24"></a><!-- doxytag: member="main.c::CurrentMeasurementComplete" ref="a24" args="()" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">__interrupt void CurrentMeasurementComplete           </td>          <td class="md" valign="top">(&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><p>Definition at line <a class="el" href="main_8c-source.html#l00544">544</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="BLDC_8h-source.html#l00207">CLEAR_ALL_TIMER0_INT_FLAGS</a>, <a class="el" href="main_8c-source.html#l00080">currentUpdated</a>, <a class="el" href="main_8c-source.html#l00071">shuntVoltageADC</a>, and <a class="el" href="BLDC_8h-source.html#l00039">TRUE</a>.<div class="fragment"><pre class="fragment"><a name="l00545"></a>00545 {<a name="l00546"></a>00546   <a class="code" href="main_8c.html#a8">shuntVoltageADC</a> = ADCH;<a name="l00547"></a>00547   <a class="code" href="main_8c.html#a11">currentUpdated</a> = <a class="code" href="BLDC_8h.html#a4">TRUE</a>;<a name="l00548"></a>00548   <a class="code" href="BLDC_8h.html#a57">CLEAR_ALL_TIMER0_INT_FLAGS</a>;<a name="l00549"></a>00549 }</pre></div><p>    </td>  </tr></table><a class="anchor" name="a23"></a><!-- doxytag: member="main.c::EnableZCDetection" ref="a23" args="()" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">__interrupt void EnableZCDetection           </td>          <td class="md" valign="top">(&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>Enables zero-cross detection. <p>This interrupt service routine is triggered when the zero cross detection hold-off time after commutation is over. All Timer/counter1 interrupts are disabled and Timer/counter0 (PWM) overflow interrupt is enabled to allow the ADC readings to be used for zero-cross detection.<p>Definition at line <a class="el" href="main_8c-source.html#l00507">507</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="main_8c-source.html#l00032">ADMUXTable</a>, <a class="el" href="BLDC_8h-source.html#l00207">CLEAR_ALL_TIMER0_INT_FLAGS</a>, <a class="el" href="BLDC_8h-source.html#l00216">CLEAR_ALL_TIMER1_INT_FLAGS</a>, <a class="el" href="BLDC_8h-source.html#l00219">DISABLE_ALL_TIMER1_INTS</a>, <a class="el" href="main_8c-source.html#l00029">driveTable</a>, <a class="el" href="main_8c-source.html#l00065">nextCommutationStep</a>, <a class="el" href="main_8c-source.html#l00050">nextDrivePattern</a>, and <a class="el" href="BLDC_8h-source.html#l00213">SET_TIMER0_INT_ZC_DETECTION</a>.<div class="fragment"><pre class="fragment"><a name="l00508"></a>00508 {<a name="l00509"></a>00509   <span class="comment">// Enable TCNT0 overflow ISR.</span><a name="l00510"></a>00510   <a class="code" href="BLDC_8h.html#a57">CLEAR_ALL_TIMER0_INT_FLAGS</a>;<a name="l00511"></a>00511   <a class="code" href="BLDC_8h.html#a60">CLEAR_ALL_TIMER1_INT_FLAGS</a>;<a name="l00512"></a>00512   <a class="code" href="BLDC_8h.html#a59">SET_TIMER0_INT_ZC_DETECTION</a>;<a name="l00513"></a>00513   <a class="code" href="BLDC_8h.html#a61">DISABLE_ALL_TIMER1_INTS</a>;<a name="l00514"></a>00514 <a name="l00515"></a>00515   <span class="comment">// Set up ADC for zero-cross detection</span><a name="l00516"></a>00516   ADMUX = <a class="code" href="main_8c.html#a1">ADMUXTable</a>[<a class="code" href="main_8c.html#a6">nextCommutationStep</a>];<a name="l00517"></a>00517 <a name="l00518"></a>00518   <span class="comment">// Wait for ADC to complete</span><a name="l00519"></a>00519   <span class="keywordflow">while</span> (!(ADCSRA &amp; (1 &lt;&lt; ADIF)))<a name="l00520"></a>00520   {<a name="l00521"></a>00521 <a name="l00522"></a>00522   }<a name="l00523"></a>00523   ADCSRA &amp;= ~(1 &lt;&lt; ADIE);<a name="l00524"></a>00524   ADCSRA |= (1 &lt;&lt; ADSC) | (1 &lt;&lt; ADATE);<a name="l00525"></a>00525 <a name="l00526"></a>00526   <span class="comment">// Rotate commutation step counter.</span><a name="l00527"></a>00527   <a class="code" href="main_8c.html#a6">nextCommutationStep</a>++;<a name="l00528"></a>00528   <span class="keywordflow">if</span> (<a class="code" href="main_8c.html#a6">nextCommutationStep</a> &gt;= 6)<a name="l00529"></a>00529   {<a name="l00530"></a>00530     <a class="code" href="main_8c.html#a6">nextCommutationStep</a> = 0;<a name="l00531"></a>00531   }<a name="l00532"></a>00532   <a class="code" href="main_8c.html#a4">nextDrivePattern</a> = <a class="code" href="main_8c.html#a0">driveTable</a>[<a class="code" href="main_8c.html#a6">nextCommutationStep</a>];<a name="l00533"></a>00533 }</pre></div><p>    </td>  </tr></table><a class="anchor" name="a16"></a><!-- doxytag: member="main.c::InitADC" ref="a16" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">static void InitADC           </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><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Initializes the AD-converter. <p>This function initializes the AD-converter and makes a reading of the external reference voltage.<p>Definition at line <a class="el" href="main_8c-source.html#l00211">211</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="BLDC_8h-source.html#l00174">ADC_PRESCALER_16</a>, <a class="el" href="BLDC_8h-source.html#l00171">ADC_PRESCALER_8</a>, <a class="el" href="BLDC_8h-source.html#l00180">ADC_TRIGGER_SOURCE</a>, <a class="el" href="BLDC_8h-source.html#l00168">ADMUX_REF_VOLTAGE</a>, and <a class="el" href="main_8c-source.html#l00074">referenceVoltageADC</a>.<div class="fragment"><pre class="fragment"><a name="l00212"></a>00212 {<a name="l00213"></a>00213   <span class="comment">// First make a measurement of the external reference voltage.</span><a name="l00214"></a>00214   ADMUX = <a class="code" href="BLDC_8h.html#a46">ADMUX_REF_VOLTAGE</a>;<a name="l00215"></a>00215   ADCSRA = (1 &lt;&lt; ADEN) | (1 &lt;&lt; ADSC) | (1 &lt;&lt; ADIF) | (<a class="code" href="BLDC_8h.html#a48">ADC_PRESCALER_16</a>);<a name="l00216"></a>00216   <span class="keywordflow">while</span> (ADCSRA &amp; (1 &lt;&lt; ADSC))<a name="l00217"></a>00217   {<a name="l00218"></a>00218 <a name="l00219"></a>00219   }<a name="l00220"></a>00220   <a class="code" href="main_8c.html#a9">referenceVoltageADC</a> = ADCH;<a name="l00221"></a>00221 <a name="l00222"></a>00222   <span class="comment">// Initialize the ADC for autotriggered operation on PWM timer overflow.</span><a name="l00223"></a>00223   ADCSRA = (1 &lt;&lt; ADEN) | (0 &lt;&lt; ADSC) | (1 &lt;&lt; ADATE) | (1 &lt;&lt; ADIF) | (0 &lt;&lt; ADIE) | <a class="code" href="BLDC_8h.html#a47">ADC_PRESCALER_8</a>;<a name="l00224"></a>00224   ADCSRB = <a class="code" href="BLDC_8h.html#a50">ADC_TRIGGER_SOURCE</a>;<a name="l00225"></a>00225 }</pre></div><p>    </td>  </tr></table><a class="anchor" name="a17"></a><!-- doxytag: member="main.c::InitAnalogComparator" ref="a17" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">static void InitAnalogComparator           </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><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>

⌨️ 快捷键说明

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