📄 main_8c.html
字号:
</td> <td><p>Initializes the analog comparator. <p>This function initializes the analog comparator for overcurrent detection.<p>Definition at line <a class="el" href="main_8c-source.html#l00232">232</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<div class="fragment"><pre class="fragment"><a name="l00233"></a>00233 {<a name="l00234"></a>00234 <span class="preprocessor">#ifdef ANALOG_COMPARATOR_ENABLE</span><a name="l00235"></a>00235 <span class="preprocessor"></span> <span class="comment">// Enable analog comparator interrupt on rising edge.</span><a name="l00236"></a>00236 ACSR = (0 << ACBG) | (1 << ACI) | (1 << ACIE) | (1 << ACIS1) | (1 << ACIS0);<a name="l00237"></a>00237 <span class="preprocessor">#endif</span><a name="l00238"></a>00238 <span class="preprocessor"></span>}</pre></div><p> </td> </tr></table><a class="anchor" name="a14"></a><!-- doxytag: member="main.c::InitPorts" ref="a14" 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 InitPorts </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>Initializes I/O ports. <p>Initializes I/O ports.<p>Definition at line <a class="el" href="main_8c-source.html#l00174">174</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="BLDC_8h-source.html#l00117">DRIVE_DDR</a>, <a class="el" href="BLDC_8h-source.html#l00045">UH</a>, <a class="el" href="BLDC_8h-source.html#l00042">UL</a>, <a class="el" href="BLDC_8h-source.html#l00051">VH</a>, <a class="el" href="BLDC_8h-source.html#l00048">VL</a>, <a class="el" href="BLDC_8h-source.html#l00057">WH</a>, and <a class="el" href="BLDC_8h-source.html#l00054">WL</a>.<div class="fragment"><pre class="fragment"><a name="l00175"></a>00175 {<a name="l00176"></a>00176 <span class="comment">// Init DRIVE_DDR for motor driving.</span><a name="l00177"></a>00177 <a class="code" href="BLDC_8h.html#a29">DRIVE_DDR</a> = (1 << <a class="code" href="BLDC_8h.html#a5">UL</a>) | (1 << <a class="code" href="BLDC_8h.html#a6">UH</a>) | (1 << <a class="code" href="BLDC_8h.html#a7">VL</a>) | (1 << <a class="code" href="BLDC_8h.html#a8">VH</a>) | (1 << <a class="code" href="BLDC_8h.html#a9">WL</a>) | (1 << <a class="code" href="BLDC_8h.html#a10">WH</a>);<a name="l00178"></a>00178 <a name="l00179"></a>00179 <span class="comment">// Init PORTD for PWM on PD5.</span><a name="l00180"></a>00180 DDRD = (1 << PD5);<a name="l00181"></a>00181 <a name="l00182"></a>00182 <span class="comment">// Disable digital input buffers on ADC channels.</span><a name="l00183"></a>00183 DIDR0 = (1 << ADC4D) | (1 << ADC3D) | (1 << ADC2D) | (1 << ADC1D) | (1 << ADC0D);<a name="l00184"></a>00184 }</pre></div><p> </td> </tr></table><a class="anchor" name="a15"></a><!-- doxytag: member="main.c::InitTimers" ref="a15" 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 InitTimers </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>Initializes timers (for commutation timing and PWM). <p>This function initializes Timer/counter0 for PWM operation for motor speed control and Timer/counter1 for commutation timing.<p>Definition at line <a class="el" href="main_8c-source.html#l00192">192</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="BLDC_8h-source.html#l00033">PWM_TOP_VALUE</a>.<div class="fragment"><pre class="fragment"><a name="l00193"></a>00193 {<a name="l00194"></a>00194 <span class="comment">// Set up Timer/counter0 for PWM, output on OCR0B, OCR0A as TOP value, prescaler = 1.</span><a name="l00195"></a>00195 TCCR0A = (0 << COM0A1) | (0 << COM0A0) | (1 << COM0B1) | (0 << COM0B0) | (0 << WGM01) | (1 << WGM00);<a name="l00196"></a>00196 TCCR0B = (1 << WGM02) | (0 << CS02) | (0 << CS01) | (1 << CS00);<a name="l00197"></a>00197 OCR0A = <a class="code" href="BLDC_8h.html#a2">PWM_TOP_VALUE</a>;<a name="l00198"></a>00198 TIFR0 = TIFR0;<a name="l00199"></a>00199 TIMSK0 = (0 << TOIE0);<a name="l00200"></a>00200 <a name="l00201"></a>00201 <span class="comment">// Set up Timer/counter1 for commutation timing, prescaler = 8.</span><a name="l00202"></a>00202 TCCR1B = (1 << CS11) | (0 << CS10);<a name="l00203"></a>00203 }</pre></div><p> </td> </tr></table><a class="anchor" name="a12"></a><!-- doxytag: member="main.c::main" ref="a12" 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">void main </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></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Program entry point. <p>Main initializes all peripheral units used and calls the startup procedure. All commutation control from that point is done in interrupt routines.<p>Definition at line <a class="el" href="main_8c-source.html#l00088">88</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="BLDC_8h.html#a89">InitADC()</a>, <a class="el" href="BLDC_8h.html#a90">InitAnalogComparator()</a>, <a class="el" href="BLDC_8h.html#a87">InitPorts()</a>, <a class="el" href="BLDC_8h.html#a88">InitTimers()</a>, <a class="el" href="BLDC_8h.html#a92">MakeTables()</a>, <a class="el" href="BLDC_8h.html#a94">PWMControl()</a>, <a class="el" href="BLDC_8h.html#a86">ResetHandler()</a>, <a class="el" href="BLDC_8h.html#a93">StartMotor()</a>, and <a class="el" href="BLDC_8h.html#a91">WatchdogTimerEnable()</a>.<div class="fragment"><pre class="fragment"><a name="l00089"></a>00089 {<a name="l00090"></a>00090 <span class="comment">// Initialize all sub-systems.</span><a name="l00091"></a>00091 <a class="code" href="BLDC_8h.html#a86">ResetHandler</a>();<a name="l00092"></a>00092 <a class="code" href="BLDC_8h.html#a87">InitPorts</a>();<a name="l00093"></a>00093 <a class="code" href="BLDC_8h.html#a88">InitTimers</a>();<a name="l00094"></a>00094 <a class="code" href="BLDC_8h.html#a89">InitADC</a>();<a name="l00095"></a>00095 <a class="code" href="BLDC_8h.html#a92">MakeTables</a>();<a name="l00096"></a>00096 <a class="code" href="BLDC_8h.html#a90">InitAnalogComparator</a>();<a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="comment">// Run startup procedure.</span><a name="l00099"></a>00099 <a class="code" href="BLDC_8h.html#a93">StartMotor</a>();<a name="l00100"></a>00100 <a name="l00101"></a>00101 <span class="comment">// Turn on watchdog for stall-detection.</span><a name="l00102"></a>00102 <a class="code" href="BLDC_8h.html#a91">WatchdogTimerEnable</a>();<a name="l00103"></a>00103 __enable_interrupt();<a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="keywordflow">for</span>(;;)<a name="l00106"></a>00106 {<a name="l00107"></a>00107 <a class="code" href="BLDC_8h.html#a94">PWMControl</a>();<a name="l00108"></a>00108 }<a name="l00109"></a>00109 }</pre></div><p><p>Here is the call graph for this function:<p><center><img src="main_8c_a12_cgraph.png" border="0" usemap="#main_8c_a12_cgraph_map" alt=""></center><map name="main_8c_a12_cgraph_map"><area href="BLDC_8h.html#a89" shape="rect" coords="155,7,222,33" alt=""><area href="BLDC_8h.html#a90" shape="rect" coords="112,57,264,84" alt=""><area href="BLDC_8h.html#a87" shape="rect" coords="152,108,224,135" alt=""><area href="BLDC_8h.html#a88" shape="rect" coords="148,159,228,185" alt=""><area href="BLDC_8h.html#a92" shape="rect" coords="142,209,235,236" alt=""><area href="BLDC_8h.html#a94" shape="rect" coords="139,260,238,287" alt=""><area href="BLDC_8h.html#a86" shape="rect" coords="136,311,240,337" alt=""><area href="BLDC_8h.html#a93" shape="rect" coords="146,361,231,388" alt=""><area href="BLDC_8h.html#a91" shape="rect" coords="110,412,267,439" alt=""></map> </td> </tr></table><a class="anchor" name="a19"></a><!-- doxytag: member="main.c::MakeTables" 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 void MakeTables </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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -