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

📄 timer128_8c-source.html

📁 ATMEL的AVR单片机库文件
💻 HTML
📖 第 1 页 / 共 3 页
字号:
00454     <span class="comment">// clear output compare value C</span>00455     outb(OCR3CH, 0);00456     outb(OCR3CL, 0);00457 }00458 <a name="l00459"></a><a class="code" href="timer128_8h.html#a73">00459</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8c.html#a43">timer3PWMOff</a>(<span class="keywordtype">void</span>)00460 {00461     <span class="comment">// turn off PWM mode on Timer3</span>00462     cbi(TCCR3A,WGMA1);00463     cbi(TCCR3A,WGMA0);00464     <span class="comment">// clear (disable) clear-timer-on-compare-match</span>00465     <span class="comment">//cbi(TCCR3B,CTC1);</span>00466     <span class="comment">// set OC3A/B/C (OutputCompare action) to none</span>00467     <a class="code" href="timer128_8c.html#a47">timer3PWMAOff</a>();00468     <a class="code" href="timer128_8c.html#a48">timer3PWMBOff</a>();00469     <a class="code" href="timer128_8c.html#a49">timer3PWMCOff</a>();00470 }00471 <a name="l00472"></a><a class="code" href="timer128_8h.html#a74">00472</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8c.html#a44">timer3PWMAOn</a>(<span class="keywordtype">void</span>)00473 {00474     <span class="comment">// turn on channel A (OC3A) PWM output</span>00475     <span class="comment">// set OC3A as non-inverted PWM</span>00476     sbi(TCCR3A,COMA1);00477     cbi(TCCR3A,COMA0);00478 }00479 <a name="l00480"></a><a class="code" href="timer128_8h.html#a75">00480</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8c.html#a45">timer3PWMBOn</a>(<span class="keywordtype">void</span>)00481 {00482     <span class="comment">// turn on channel B (OC3B) PWM output</span>00483     <span class="comment">// set OC3B as non-inverted PWM</span>00484     sbi(TCCR3A,COMB1);00485     cbi(TCCR3A,COMB0);00486 }00487 <a name="l00488"></a><a class="code" href="timer128_8h.html#a76">00488</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8c.html#a46">timer3PWMCOn</a>(<span class="keywordtype">void</span>)00489 {00490     <span class="comment">// turn on channel C (OC3C) PWM output</span>00491     <span class="comment">// set OC3C as non-inverted PWM</span>00492     sbi(TCCR3A,COMC1);00493     cbi(TCCR3A,COMC0);00494 }00495 <a name="l00496"></a><a class="code" href="timer128_8h.html#a77">00496</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8c.html#a47">timer3PWMAOff</a>(<span class="keywordtype">void</span>)00497 {00498     <span class="comment">// turn off channel A (OC3A) PWM output</span>00499     <span class="comment">// set OC3A (OutputCompare action) to none</span>00500     cbi(TCCR3A,COMA1);00501     cbi(TCCR3A,COMA0);00502 }00503 <a name="l00504"></a><a class="code" href="timer128_8h.html#a78">00504</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8c.html#a48">timer3PWMBOff</a>(<span class="keywordtype">void</span>)00505 {00506     <span class="comment">// turn off channel B (OC3B) PWM output</span>00507     <span class="comment">// set OC3B (OutputCompare action) to none</span>00508     cbi(TCCR3A,COMB1);00509     cbi(TCCR3A,COMB0);00510 }00511 <a name="l00512"></a><a class="code" href="timer128_8h.html#a79">00512</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8c.html#a49">timer3PWMCOff</a>(<span class="keywordtype">void</span>)00513 {00514     <span class="comment">// turn off channel C (OC3C) PWM output</span>00515     <span class="comment">// set OC3C (OutputCompare action) to none</span>00516     cbi(TCCR3A,COMC1);00517     cbi(TCCR3A,COMC0);00518 }00519 <a name="l00520"></a><a class="code" href="timer128_8h.html#a80">00520</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8h.html#a80">timer3PWMASet</a>(u16 pwmDuty)00521 {00522     <span class="comment">// set PWM (output compare) duty for channel A</span>00523     <span class="comment">// this PWM output is generated on OC3A pin</span>00524     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00525     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00526     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00527     outp( (pwmDuty&gt;&gt;8), OCR3AH);        <span class="comment">// set the high 8bits of OCR3A</span>00528     outp( (pwmDuty&amp;0x00FF), OCR3AL);    <span class="comment">// set the low 8bits of OCR3A</span>00529 }00530 <a name="l00531"></a><a class="code" href="timer128_8h.html#a81">00531</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8h.html#a81">timer3PWMBSet</a>(u16 pwmDuty)00532 {00533     <span class="comment">// set PWM (output compare) duty for channel B</span>00534     <span class="comment">// this PWM output is generated on OC3B pin</span>00535     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00536     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00537     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00538     outp( (pwmDuty&gt;&gt;8), OCR3BH);        <span class="comment">// set the high 8bits of OCR3B</span>00539     outp( (pwmDuty&amp;0x00FF), OCR3BL);    <span class="comment">// set the low 8bits of OCR3B</span>00540 }00541 <a name="l00542"></a><a class="code" href="timer128_8h.html#a82">00542</a> <span class="keywordtype">void</span> <a class="code" href="timer128_8h.html#a82">timer3PWMCSet</a>(u16 pwmDuty)00543 {00544     <span class="comment">// set PWM (output compare) duty for channel B</span>00545     <span class="comment">// this PWM output is generated on OC3C pin</span>00546     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00547     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00548     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00549     outp( (pwmDuty&gt;&gt;8), OCR3CH);        <span class="comment">// set the high 8bits of OCR3C</span>00550     outp( (pwmDuty&amp;0x00FF), OCR3CL);    <span class="comment">// set the low 8bits of OCR3C</span>00551 }00552 00553 <span class="comment"></span>00554 <span class="comment">//! Interrupt handler for tcnt0 overflow interrupt</span><a name="l00555"></a><a class="code" href="timer128_8c.html#a53">00555</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OVERFLOW0)00556 {00557     Timer0Reg0++;       <span class="comment">// increment low-order counter</span>00558     <span class="keywordflow">if</span>(!Timer0Reg0)     <span class="comment">// if low-order counter rollover</span>00559         Timer0Reg1++;   <span class="comment">// increment high-order counter </span>00560 00561     <span class="comment">// if a user function is defined, execute it too</span>00562     <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OVERFLOW_INT])00563         TimerIntFunc[TIMER0OVERFLOW_INT]();00564 }00565 <span class="comment"></span>00566 <span class="comment">//! Interrupt handler for Timer1 overflow interrupt</span><a name="l00567"></a><a class="code" href="timer128_8c.html#a54">00567</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OVERFLOW1)00568 {00569     <span class="comment">// if a user function is defined, execute it</span>00570     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OVERFLOW_INT])00571         TimerIntFunc[TIMER1OVERFLOW_INT]();00572 }00573 <span class="comment"></span>00574 <span class="comment">//! Interrupt handler for Timer2 overflow interrupt</span><a name="l00575"></a><a class="code" href="timer128_8c.html#a55">00575</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OVERFLOW2)00576 {00577     Timer2Reg0++;       <span class="comment">// increment low-order counter</span>00578     <span class="keywordflow">if</span>(!Timer2Reg0)     <span class="comment">// if low-order counter rollover</span>00579         Timer2Reg1++;   <span class="comment">// increment high-order counter </span>00580 00581     <span class="comment">// increment pause counter</span>00582     TimerPauseReg++;00583 00584     <span class="comment">// if a user function is defined, execute it</span>00585     <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OVERFLOW_INT])00586         TimerIntFunc[TIMER2OVERFLOW_INT]();00587 }00588 <span class="comment"></span>00589 <span class="comment">//! Interrupt handler for Timer3 overflow interrupt</span><a name="l00590"></a><a class="code" href="timer128_8c.html#a56">00590</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OVERFLOW3)00591 {00592     <span class="comment">// if a user function is defined, execute it</span>00593     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OVERFLOW_INT])00594         TimerIntFunc[TIMER3OVERFLOW_INT]();00595 }00596 <span class="comment"></span>00597 <span class="comment">//! Interrupt handler for OutputCompare0 match (OC0) interrupt</span><a name="l00598"></a><a class="code" href="timer128_8c.html#a57">00598</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE0)00599 {00600     <span class="comment">// if a user function is defined, execute it</span>00601     <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OUTCOMPARE_INT])00602         TimerIntFunc[TIMER0OUTCOMPARE_INT]();00603 }00604 <span class="comment"></span>00605 <span class="comment">//! Interrupt handler for OutputCompare1A match (OC1A) interrupt</span><a name="l00606"></a><a class="code" href="timer128_8c.html#a58">00606</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE1A)00607 {00608     <span class="comment">// if a user function is defined, execute it</span>00609     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREA_INT])00610         TimerIntFunc[TIMER1OUTCOMPAREA_INT]();00611 }00612 <span class="comment"></span>00613 <span class="comment">//! Interrupt handler for OutputCompare1B match (OC1B) interrupt</span><a name="l00614"></a><a class="code" href="timer128_8c.html#a59">00614</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE1B)00615 {00616     <span class="comment">// if a user function is defined, execute it</span>00617     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREB_INT])00618         TimerIntFunc[TIMER1OUTCOMPAREB_INT]();00619 }00620 <span class="comment"></span>00621 <span class="comment">//! Interrupt handler for OutputCompare1C match (OC1C) interrupt</span><a name="l00622"></a><a class="code" href="timer128_8c.html#a60">00622</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE1C)00623 {00624     <span class="comment">// if a user function is defined, execute it</span>00625     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREC_INT])00626         TimerIntFunc[TIMER1OUTCOMPAREC_INT]();00627 }00628 <span class="comment"></span>00629 <span class="comment">//! Interrupt handler for InputCapture1(IC1) interrupt</span><a name="l00630"></a><a class="code" href="timer128_8c.html#a61">00630</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_INPUT_CAPTURE1)00631 {00632     <span class="comment">// if a user function is defined, execute it</span>00633     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1INPUTCAPTURE_INT])00634         TimerIntFunc[TIMER1INPUTCAPTURE_INT]();00635 }00636 <span class="comment"></span>00637 <span class="comment">//! Interrupt handler for OutputCompare2 match (OC2) interrupt</span><a name="l00638"></a><a class="code" href="timer128_8c.html#a62">00638</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE2)00639 {00640     <span class="comment">// if a user function is defined, execute it</span>00641     <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OUTCOMPARE_INT])00642         TimerIntFunc[TIMER2OUTCOMPARE_INT]();00643 }00644 <span class="comment"></span>00645 <span class="comment">//! Interrupt handler for OutputCompare3A match (OC3A) interrupt</span><a name="l00646"></a><a class="code" href="timer128_8c.html#a63">00646</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE3A)00647 {00648     <span class="comment">// if a user function is defined, execute it</span>00649     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREA_INT])00650         TimerIntFunc[TIMER3OUTCOMPAREA_INT]();00651 }00652 <span class="comment"></span>00653 <span class="comment">//! Interrupt handler for OutputCompare3B match (OC3B) interrupt</span><a name="l00654"></a><a class="code" href="timer128_8c.html#a64">00654</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE3B)00655 {00656     <span class="comment">// if a user function is defined, execute it</span>00657     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREB_INT])00658         TimerIntFunc[TIMER3OUTCOMPAREB_INT]();00659 }00660 <span class="comment"></span>00661 <span class="comment">//! Interrupt handler for OutputCompare3C match (OC3C) interrupt</span><a name="l00662"></a><a class="code" href="timer128_8c.html#a65">00662</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_OUTPUT_COMPARE3C)00663 {00664     <span class="comment">// if a user function is defined, execute it</span>00665     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREC_INT])00666         TimerIntFunc[TIMER3OUTCOMPAREC_INT]();00667 }00668 <span class="comment"></span>00669 <span class="comment">//! Interrupt handler for InputCapture3 (IC3) interrupt</span><a name="l00670"></a><a class="code" href="timer128_8c.html#a66">00670</a> <span class="comment"></span><a class="code" href="timer128_8c.html#a66">TIMER_INTERRUPT_HANDLER</a>(SIG_INPUT_CAPTURE3)00671 {00672     <span class="comment">// if a user function is defined, execute it</span>00673     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3INPUTCAPTURE_INT])00674         TimerIntFunc[TIMER3INPUTCAPTURE_INT]();00675 }</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Oct 15 03:50:22 2004 for Procyon AVRlib by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6 </small></address></body></html>

⌨️ 快捷键说明

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