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

📄 timer_8c-source.html

📁 avr应用测试程序
💻 HTML
📖 第 1 页 / 共 3 页
字号:
00316     sbi(TCCR1B,WGM13);00317     00318     <span class="comment">// set top count value</span>00319     ICR1 = topcount;00320     00321     <span class="comment">// clear output compare value A</span>00322     OCR1A = 0;00323     <span class="comment">// clear output compare value B</span>00324     OCR1B = 0;00325 00326 }00327 <span class="preprocessor">#endif</span>00328 <span class="preprocessor"></span><a name="l00329"></a><a class="code" href="group__timer128.html#ga23">00329</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga2">timer1PWMOff</a>(<span class="keywordtype">void</span>)00330 {00331     <span class="comment">// turn off timer1 PWM mode</span>00332     cbi(TCCR1A,PWM11);00333     cbi(TCCR1A,PWM10);00334     <span class="comment">// set PWM1A/B (OutputCompare action) to none</span>00335     <a class="code" href="group__timerpwm.html#ga5">timer1PWMAOff</a>();00336     <a class="code" href="group__timerpwm.html#ga6">timer1PWMBOff</a>();00337 }00338 <a name="l00339"></a><a class="code" href="group__timer128.html#ga24">00339</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga3">timer1PWMAOn</a>(<span class="keywordtype">void</span>)00340 {00341     <span class="comment">// turn on channel A (OC1A) PWM output</span>00342     <span class="comment">// set OC1A as non-inverted PWM</span>00343     sbi(TCCR1A,COM1A1);00344     cbi(TCCR1A,COM1A0);00345 }00346 <a name="l00347"></a><a class="code" href="group__timer128.html#ga25">00347</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga4">timer1PWMBOn</a>(<span class="keywordtype">void</span>)00348 {00349     <span class="comment">// turn on channel B (OC1B) PWM output</span>00350     <span class="comment">// set OC1B as non-inverted PWM</span>00351     sbi(TCCR1A,COM1B1);00352     cbi(TCCR1A,COM1B0);00353 }00354 <a name="l00355"></a><a class="code" href="group__timer128.html#ga27">00355</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga5">timer1PWMAOff</a>(<span class="keywordtype">void</span>)00356 {00357     <span class="comment">// turn off channel A (OC1A) PWM output</span>00358     <span class="comment">// set OC1A (OutputCompare action) to none</span>00359     cbi(TCCR1A,COM1A1);00360     cbi(TCCR1A,COM1A0);00361 }00362 <a name="l00363"></a><a class="code" href="group__timer128.html#ga28">00363</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga6">timer1PWMBOff</a>(<span class="keywordtype">void</span>)00364 {00365     <span class="comment">// turn off channel B (OC1B) PWM output</span>00366     <span class="comment">// set OC1B (OutputCompare action) to none</span>00367     cbi(TCCR1A,COM1B1);00368     cbi(TCCR1A,COM1B0);00369 }00370 <a name="l00371"></a><a class="code" href="group__timer128.html#ga30">00371</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga7">timer1PWMASet</a>(u16 pwmDuty)00372 {00373     <span class="comment">// set PWM (output compare) duty for channel A</span>00374     <span class="comment">// this PWM output is generated on OC1A pin</span>00375     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00376     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00377     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00378     <span class="comment">//outp( (pwmDuty&gt;&gt;8), OCR1AH);      // set the high 8bits of OCR1A</span>00379     <span class="comment">//outp( (pwmDuty&amp;0x00FF), OCR1AL);  // set the low 8bits of OCR1A</span>00380     OCR1A = pwmDuty;00381 }00382 <a name="l00383"></a><a class="code" href="group__timer128.html#ga31">00383</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga8">timer1PWMBSet</a>(u16 pwmDuty)00384 {00385     <span class="comment">// set PWM (output compare) duty for channel B</span>00386     <span class="comment">// this PWM output is generated on OC1B pin</span>00387     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00388     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00389     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00390     <span class="comment">//outp( (pwmDuty&gt;&gt;8), OCR1BH);      // set the high 8bits of OCR1B</span>00391     <span class="comment">//outp( (pwmDuty&amp;0x00FF), OCR1BL);  // set the low 8bits of OCR1B</span>00392     OCR1B = pwmDuty;00393 }00394 <span class="comment"></span>00395 <span class="comment">//! Interrupt handler for tcnt0 overflow interrupt</span><a name="l00396"></a><a class="code" href="timer_8c.html#a27">00396</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)00397 {00398     Timer0Reg0++;           <span class="comment">// increment low-order counter</span>00399 00400     <span class="comment">// increment pause counter</span>00401     TimerPauseReg++;00402 00403     <span class="comment">// if a user function is defined, execute it too</span>00404     <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OVERFLOW_INT])00405         TimerIntFunc[TIMER0OVERFLOW_INT]();00406 }00407 <span class="comment"></span>00408 <span class="comment">//! Interrupt handler for tcnt1 overflow interrupt</span><a name="l00409"></a><a class="code" href="timer_8c.html#a28">00409</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1)00410 {00411     <span class="comment">// if a user function is defined, execute it</span>00412     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OVERFLOW_INT])00413         TimerIntFunc[TIMER1OVERFLOW_INT]();00414 }00415 00416 <span class="preprocessor">#ifdef TCNT2    // support timer2 only if it exists</span>00417 <span class="preprocessor"></span><span class="comment">//! Interrupt handler for tcnt2 overflow interrupt</span>00418 <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW2)00419 {00420     Timer2Reg0++;           <span class="comment">// increment low-order counter</span>00421 00422     <span class="comment">// if a user function is defined, execute it</span>00423     <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OVERFLOW_INT])00424         TimerIntFunc[TIMER2OVERFLOW_INT]();00425 }00426 <span class="preprocessor">#endif</span>00427 <span class="preprocessor"></span>00428 <span class="preprocessor">#ifdef OCR0</span>00429 <span class="preprocessor"></span><span class="comment">// include support for Output Compare 0 for new AVR processors that support it</span><span class="comment"></span>00430 <span class="comment">//! Interrupt handler for OutputCompare0 match (OC0) interrupt</span>00431 <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)00432 {00433     <span class="comment">// if a user function is defined, execute it</span>00434     <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OUTCOMPARE_INT])00435         TimerIntFunc[TIMER0OUTCOMPARE_INT]();00436 }00437 <span class="preprocessor">#endif</span>00438 <span class="preprocessor"></span><span class="comment"></span>00439 <span class="comment">//! Interrupt handler for CutputCompare1A match (OC1A) interrupt</span><a name="l00440"></a><a class="code" href="timer_8c.html#a29">00440</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1A)00441 {00442     <span class="comment">// if a user function is defined, execute it</span>00443     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREA_INT])00444         TimerIntFunc[TIMER1OUTCOMPAREA_INT]();00445 }00446 <span class="comment"></span>00447 <span class="comment">//! Interrupt handler for OutputCompare1B match (OC1B) interrupt</span><a name="l00448"></a><a class="code" href="timer_8c.html#a30">00448</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1B)00449 {00450     <span class="comment">// if a user function is defined, execute it</span>00451     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREB_INT])00452         TimerIntFunc[TIMER1OUTCOMPAREB_INT]();00453 }00454 <span class="comment"></span>00455 <span class="comment">//! Interrupt handler for InputCapture1 (IC1) interrupt</span><a name="l00456"></a><a class="code" href="timer_8c.html#a31">00456</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE1)00457 {00458     <span class="comment">// if a user function is defined, execute it</span>00459     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1INPUTCAPTURE_INT])00460         TimerIntFunc[TIMER1INPUTCAPTURE_INT]();00461 }00462 <span class="comment"></span>00463 <span class="comment">//! Interrupt handler for OutputCompare2 match (OC2) interrupt</span><a name="l00464"></a><a class="code" href="timer_8c.html#a32">00464</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE2)00465 {00466     <span class="comment">// if a user function is defined, execute it</span>00467     <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OUTCOMPARE_INT])00468         TimerIntFunc[TIMER2OUTCOMPARE_INT]();00469 }</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address></body></html>

⌨️ 快捷键说明

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