📄 main_8c.html
字号:
Disables PWM outputs by setting the port direction to input for the PWM pins.<p>Definition at line <a class="el" href="main_8c-source.html#l00628">628</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="PMSM_8h-source.html#l00091">PWM_PIN_MASK_PORTB</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00965">Timer1OverflowISR()</a>, <a class="el" href="main_8c-source.html#l00353">TimerSetModeBlockCommutation()</a>, <a class="el" href="main_8c-source.html#l00385">TimerSetModeBrake()</a>, and <a class="el" href="main_8c-source.html#l00317">TimerSetModeSinusoidal()</a>.<div class="fragment"><pre class="fragment"><a name="l00629"></a>00629 {<a name="l00630"></a>00630 DDRB &= (~<a class="code" href="PMSM_8h.html#a11">PWM_PIN_MASK_PORTB</a>);<a name="l00631"></a>00631 }</pre></div><p> </td> </tr></table><a class="anchor" name="a27"></a><!-- doxytag: member="main.c::EnablePWMOutputs" ref="a27" 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 EnablePWMOutputs </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [static]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Enable PWM outputs by setting the port direction to output. <p>Enables PWM outputs by setting the port direction to output for the PWM pins.<p>Definition at line <a class="el" href="main_8c-source.html#l00617">617</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="PMSM_8h-source.html#l00091">PWM_PIN_MASK_PORTB</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00353">TimerSetModeBlockCommutation()</a>, <a class="el" href="main_8c-source.html#l00385">TimerSetModeBrake()</a>, and <a class="el" href="main_8c-source.html#l00317">TimerSetModeSinusoidal()</a>.<div class="fragment"><pre class="fragment"><a name="l00618"></a>00618 {<a name="l00619"></a>00619 DDRB |= <a class="code" href="PMSM_8h.html#a11">PWM_PIN_MASK_PORTB</a>;<a name="l00620"></a>00620 }</pre></div><p> </td> </tr></table><a class="anchor" name="a35"></a><!-- doxytag: member="main.c::FaultProtectionISR" ref="a35" 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 FaultProtectionISR </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Hardware fault protection interrupt. <p>This ISR will be run every time the hardware fault protection disables the PWM outputs. The required action to this event will be different from application to application. Here, a delay is inserted, before the PWM outputs are once again enabled.<p>Definition at line <a class="el" href="main_8c-source.html#l01029">1029</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="pid_8c-source.html#l00117">pid_Reset_Integrator()</a>.<div class="fragment"><pre class="fragment"><a name="l01030"></a>01030 {<a name="l01031"></a>01031 __delay_cycles(10000000);<a name="l01032"></a>01032 TCCR1D |= (1 << FPEN1);<a name="l01033"></a>01033 <span class="preprocessor">#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP)</span><a name="l01034"></a>01034 <span class="preprocessor"></span> <a class="code" href="pid_8c.html#a2">pid_Reset_Integrator</a>(&pidParameters);<a name="l01035"></a>01035 <span class="preprocessor">#endif</span><a name="l01036"></a>01036 <span class="preprocessor"></span>}</pre></div><p><p>Here is the call graph for this function:<p><center><img src="main_8c_a35_cgraph.png" border="0" usemap="#main_8c_a35_cgraph_map" alt=""></center><map name="main_8c_a35_cgraph_map"><area href="pid_8c.html#a2" shape="rect" coords="189,5,336,32" alt=""></map> </td> </tr></table><a class="anchor" name="a19"></a><!-- doxytag: member="main.c::GetDesiredDirection" ref="a19" 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 <a class="el" href="stdint_8h.html#a56">uint8_t</a> GetDesiredDirection </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [static]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Returns the desired direction. <p>This function returns the current desired direction. <dl compact><dt><b>Note:</b></dt><dd>The direction input is not read at this time. A separate pin change interrupt is responsible for reading the input.</dd></dl><dl compact><dt><b>Return values:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>DIRECTION_FORWARD</em> </td><td>Forward direction is requested. </td></tr> <tr><td valign="top"></td><td valign="top"><em>DIRECTION_REVERSE</em> </td><td>Reverse direction is requested.</td></tr> </table></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00437">437</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00643">CommutationTicksUpdate()</a>, <a class="el" href="main_8c-source.html#l00888">HallChangeISR()</a>, and <a class="el" href="main_8c-source.html#l00750">SineOutputUpdate()</a>.<div class="fragment"><pre class="fragment"><a name="l00438"></a>00438 {<a name="l00439"></a>00439 <span class="keywordflow">return</span> (<a class="code" href="stdint_8h.html#a56">uint8_t</a>)fastFlags.desiredDirection;<a name="l00440"></a>00440 }</pre></div><p> </td> </tr></table><a class="anchor" name="a21"></a><!-- doxytag: member="main.c::GetHall" ref="a21" 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 <a class="el" href="stdint_8h.html#a56">uint8_t</a> GetHall </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [static]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Reads the hall sensor inputs. <p>This function reads the hall sensor inputs and converts it to a number from 1 to 6 by combining the hall sensors as bits: H3|H2|H1.<p><dl compact><dt><b>Note:</b></dt><dd>It is possible to change the physical placement of hall sensor inputs, but the recommended configuration is the one used in this example, since it requires very little code to decode the hall values.</dd></dl><dl compact><dt><b>Returns:</b></dt><dd>The decoded hall sensor value.</dd></dl><dl compact><dt><b>Return values:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>Illegal hall state. Possible hardware error. </td></tr> <tr><td valign="top"></td><td valign="top"><em>1-6</em> </td><td>Legal hall sensor values. </td></tr> <tr><td valign="top"></td><td valign="top"><em>7</em> </td><td>Illegal hall state. Possible hardware error.</td></tr> </table></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00484">484</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="PMSM_8h-source.html#l00095">H1_PIN</a>, <a class="el" href="PMSM_8h-source.html#l00098">H2_PIN</a>, and <a class="el" href="PMSM_8h-source.html#l00101">H3_PIN</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00643">CommutationTicksUpdate()</a>, and <a class="el" href="main_8c-source.html#l00888">HallChangeISR()</a>.<div class="fragment"><pre class="fragment"><a name="l00485"></a>00485 {<a name="l00486"></a>00486 <a class="code" href="stdint_8h.html#a56">uint8_t</a> hall;<a name="l00487"></a>00487 <a name="l00488"></a>00488 hall = (PINA) & ((1 << <a class="code" href="PMSM_8h.html#a14">H3_PIN</a>) | (1 << <a class="code" href="PMSM_8h.html#a13">H2_PIN</a>) | (1 << <a class="code" href="PMSM_8h.html#a12">H1_PIN</a>));<a name="l00489"></a>00489 hall >>= <a class="code" href="PMSM_8h.html#a12">H1_PIN</a>;<a name="l00490"></a>00490 <span class="keywordflow">return</span> hall;<a name="l00491"></a>00491 }</pre></div><p> </td> </tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -