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

📄 timer128_8c-source.html

📁 avr cpu 库源代码 对avr单片机编程很有帮助
💻 HTML
📖 第 1 页 / 共 3 页
字号:
00462     <span class="comment">// clear output compare value A</span>00463     outb(OCR3AH, 0);00464     outb(OCR3AL, 0);00465     <span class="comment">// clear output compare value B</span>00466     outb(OCR3BH, 0);00467     outb(OCR3BL, 0);00468     <span class="comment">// clear output compare value C</span>00469     outb(OCR3CH, 0);00470     outb(OCR3CL, 0);00471 }00472 <a name="l00473"></a><a class="code" href="group__timer128.html#ga35">00473</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga35">timer3PWMOff</a>(<span class="keywordtype">void</span>)00474 {00475     <span class="comment">// turn off PWM mode on Timer3</span>00476     cbi(TCCR3A,WGMA1);00477     cbi(TCCR3A,WGMA0);00478     <span class="comment">// clear (disable) clear-timer-on-compare-match</span>00479     <span class="comment">//cbi(TCCR3B,CTC1);</span>00480     <span class="comment">// set OC3A/B/C (OutputCompare action) to none</span>00481     <a class="code" href="group__timer128.html#ga39">timer3PWMAOff</a>();00482     <a class="code" href="group__timer128.html#ga40">timer3PWMBOff</a>();00483     <a class="code" href="group__timer128.html#ga41">timer3PWMCOff</a>();00484 }00485 <a name="l00486"></a><a class="code" href="group__timer128.html#ga36">00486</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga36">timer3PWMAOn</a>(<span class="keywordtype">void</span>)00487 {00488     <span class="comment">// turn on channel A (OC3A) PWM output</span>00489     <span class="comment">// set OC3A as non-inverted PWM</span>00490     sbi(TCCR3A,COMA1);00491     cbi(TCCR3A,COMA0);00492 }00493 <a name="l00494"></a><a class="code" href="group__timer128.html#ga37">00494</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga37">timer3PWMBOn</a>(<span class="keywordtype">void</span>)00495 {00496     <span class="comment">// turn on channel B (OC3B) PWM output</span>00497     <span class="comment">// set OC3B as non-inverted PWM</span>00498     sbi(TCCR3A,COMB1);00499     cbi(TCCR3A,COMB0);00500 }00501 <a name="l00502"></a><a class="code" href="group__timer128.html#ga38">00502</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga38">timer3PWMCOn</a>(<span class="keywordtype">void</span>)00503 {00504     <span class="comment">// turn on channel C (OC3C) PWM output</span>00505     <span class="comment">// set OC3C as non-inverted PWM</span>00506     sbi(TCCR3A,COMC1);00507     cbi(TCCR3A,COMC0);00508 }00509 <a name="l00510"></a><a class="code" href="group__timer128.html#ga39">00510</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga39">timer3PWMAOff</a>(<span class="keywordtype">void</span>)00511 {00512     <span class="comment">// turn off channel A (OC3A) PWM output</span>00513     <span class="comment">// set OC3A (OutputCompare action) to none</span>00514     cbi(TCCR3A,COMA1);00515     cbi(TCCR3A,COMA0);00516 }00517 <a name="l00518"></a><a class="code" href="group__timer128.html#ga40">00518</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga40">timer3PWMBOff</a>(<span class="keywordtype">void</span>)00519 {00520     <span class="comment">// turn off channel B (OC3B) PWM output</span>00521     <span class="comment">// set OC3B (OutputCompare action) to none</span>00522     cbi(TCCR3A,COMB1);00523     cbi(TCCR3A,COMB0);00524 }00525 <a name="l00526"></a><a class="code" href="group__timer128.html#ga41">00526</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga41">timer3PWMCOff</a>(<span class="keywordtype">void</span>)00527 {00528     <span class="comment">// turn off channel C (OC3C) PWM output</span>00529     <span class="comment">// set OC3C (OutputCompare action) to none</span>00530     cbi(TCCR3A,COMC1);00531     cbi(TCCR3A,COMC0);00532 }00533 <a name="l00534"></a><a class="code" href="group__timer128.html#ga42">00534</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga42">timer3PWMASet</a>(u16 pwmDuty)00535 {00536     <span class="comment">// set PWM (output compare) duty for channel A</span>00537     <span class="comment">// this PWM output is generated on OC3A pin</span>00538     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00539     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00540     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00541     outb(OCR3AH, (pwmDuty&gt;&gt;8));     <span class="comment">// set the high 8bits of OCR3A</span>00542     outb(OCR3AL, (pwmDuty&amp;0x00FF)); <span class="comment">// set the low 8bits of OCR3A</span>00543 }00544 <a name="l00545"></a><a class="code" href="group__timer128.html#ga43">00545</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga43">timer3PWMBSet</a>(u16 pwmDuty)00546 {00547     <span class="comment">// set PWM (output compare) duty for channel B</span>00548     <span class="comment">// this PWM output is generated on OC3B pin</span>00549     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00550     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00551     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00552     outb(OCR3BH, (pwmDuty&gt;&gt;8));     <span class="comment">// set the high 8bits of OCR3B</span>00553     outb(OCR3BL, (pwmDuty&amp;0x00FF)); <span class="comment">// set the low 8bits of OCR3B</span>00554 }00555 <a name="l00556"></a><a class="code" href="group__timer128.html#ga44">00556</a> <span class="keywordtype">void</span> <a class="code" href="group__timer128.html#ga44">timer3PWMCSet</a>(u16 pwmDuty)00557 {00558     <span class="comment">// set PWM (output compare) duty for channel B</span>00559     <span class="comment">// this PWM output is generated on OC3C pin</span>00560     <span class="comment">// NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM</span>00561     <span class="comment">//          pwmDuty should be in the range 0-511 for 9bit PWM</span>00562     <span class="comment">//          pwmDuty should be in the range 0-1023 for 10bit PWM</span>00563     outb(OCR3CH, (pwmDuty&gt;&gt;8));     <span class="comment">// set the high 8bits of OCR3C</span>00564     outb(OCR3CL, (pwmDuty&amp;0x00FF)); <span class="comment">// set the low 8bits of OCR3C</span>00565 }00566 00567 <span class="comment"></span>00568 <span class="comment">//! Interrupt handler for tcnt0 overflow interrupt</span><a name="l00569"></a><a class="code" href="timer128_8c.html#a53">00569</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)00570 {00571     Timer0Reg0++;       <span class="comment">// increment low-order counter</span>00572     <span class="keywordflow">if</span>(!Timer0Reg0)     <span class="comment">// if low-order counter rollover</span>00573         Timer0Reg1++;   <span class="comment">// increment high-order counter </span>00574 00575     <span class="comment">// if a user function is defined, execute it too</span>00576     <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OVERFLOW_INT])00577         TimerIntFunc[TIMER0OVERFLOW_INT]();00578 }00579 <span class="comment"></span>00580 <span class="comment">//! Interrupt handler for Timer1 overflow interrupt</span><a name="l00581"></a><a class="code" href="timer128_8c.html#a54">00581</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1)00582 {00583     <span class="comment">// if a user function is defined, execute it</span>00584     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OVERFLOW_INT])00585         TimerIntFunc[TIMER1OVERFLOW_INT]();00586 }00587 <span class="comment"></span>00588 <span class="comment">//! Interrupt handler for Timer2 overflow interrupt</span><a name="l00589"></a><a class="code" href="timer128_8c.html#a55">00589</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW2)00590 {00591     Timer2Reg0++;       <span class="comment">// increment low-order counter</span>00592     <span class="keywordflow">if</span>(!Timer2Reg0)     <span class="comment">// if low-order counter rollover</span>00593         Timer2Reg1++;   <span class="comment">// increment high-order counter </span>00594 00595     <span class="comment">// increment pause counter</span>00596     TimerPauseReg++;00597 00598     <span class="comment">// if a user function is defined, execute it</span>00599     <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OVERFLOW_INT])00600         TimerIntFunc[TIMER2OVERFLOW_INT]();00601 }00602 <span class="comment"></span>00603 <span class="comment">//! Interrupt handler for Timer3 overflow interrupt</span><a name="l00604"></a><a class="code" href="timer128_8c.html#a56">00604</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW3)00605 {00606     <span class="comment">// if a user function is defined, execute it</span>00607     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OVERFLOW_INT])00608         TimerIntFunc[TIMER3OVERFLOW_INT]();00609 }00610 <span class="comment"></span>00611 <span class="comment">//! Interrupt handler for OutputCompare0 match (OC0) interrupt</span><a name="l00612"></a><a class="code" href="timer128_8c.html#a57">00612</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)00613 {00614     <span class="comment">// if a user function is defined, execute it</span>00615     <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OUTCOMPARE_INT])00616         TimerIntFunc[TIMER0OUTCOMPARE_INT]();00617 }00618 <span class="comment"></span>00619 <span class="comment">//! Interrupt handler for OutputCompare1A match (OC1A) interrupt</span><a name="l00620"></a><a class="code" href="timer128_8c.html#a58">00620</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1A)00621 {00622     <span class="comment">// if a user function is defined, execute it</span>00623     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREA_INT])00624         TimerIntFunc[TIMER1OUTCOMPAREA_INT]();00625 }00626 <span class="comment"></span>00627 <span class="comment">//! Interrupt handler for OutputCompare1B match (OC1B) interrupt</span><a name="l00628"></a><a class="code" href="timer128_8c.html#a59">00628</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1B)00629 {00630     <span class="comment">// if a user function is defined, execute it</span>00631     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREB_INT])00632         TimerIntFunc[TIMER1OUTCOMPAREB_INT]();00633 }00634 <span class="comment"></span>00635 <span class="comment">//! Interrupt handler for OutputCompare1C match (OC1C) interrupt</span><a name="l00636"></a><a class="code" href="timer128_8c.html#a60">00636</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1C)00637 {00638     <span class="comment">// if a user function is defined, execute it</span>00639     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREC_INT])00640         TimerIntFunc[TIMER1OUTCOMPAREC_INT]();00641 }00642 <span class="comment"></span>00643 <span class="comment">//! Interrupt handler for InputCapture1(IC1) interrupt</span><a name="l00644"></a><a class="code" href="timer128_8c.html#a61">00644</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE1)00645 {00646     <span class="comment">// if a user function is defined, execute it</span>00647     <span class="keywordflow">if</span>(TimerIntFunc[TIMER1INPUTCAPTURE_INT])00648         TimerIntFunc[TIMER1INPUTCAPTURE_INT]();00649 }00650 <span class="comment"></span>00651 <span class="comment">//! Interrupt handler for OutputCompare2 match (OC2) interrupt</span><a name="l00652"></a><a class="code" href="timer128_8c.html#a62">00652</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE2)00653 {00654     <span class="comment">// if a user function is defined, execute it</span>00655     <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OUTCOMPARE_INT])00656         TimerIntFunc[TIMER2OUTCOMPARE_INT]();00657 }00658 <span class="comment"></span>00659 <span class="comment">//! Interrupt handler for OutputCompare3A match (OC3A) interrupt</span><a name="l00660"></a><a class="code" href="timer128_8c.html#a63">00660</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3A)00661 {00662     <span class="comment">// if a user function is defined, execute it</span>00663     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREA_INT])00664         TimerIntFunc[TIMER3OUTCOMPAREA_INT]();00665 }00666 <span class="comment"></span>00667 <span class="comment">//! Interrupt handler for OutputCompare3B match (OC3B) interrupt</span><a name="l00668"></a><a class="code" href="timer128_8c.html#a64">00668</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3B)00669 {00670     <span class="comment">// if a user function is defined, execute it</span>00671     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREB_INT])00672         TimerIntFunc[TIMER3OUTCOMPAREB_INT]();00673 }00674 <span class="comment"></span>00675 <span class="comment">//! Interrupt handler for OutputCompare3C match (OC3C) interrupt</span><a name="l00676"></a><a class="code" href="timer128_8c.html#a65">00676</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3C)00677 {00678     <span class="comment">// if a user function is defined, execute it</span>00679     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3OUTCOMPAREC_INT])00680         TimerIntFunc[TIMER3OUTCOMPAREC_INT]();00681 }00682 <span class="comment"></span>00683 <span class="comment">//! Interrupt handler for InputCapture3 (IC3) interrupt</span><a name="l00684"></a><a class="code" href="timer128_8c.html#a66">00684</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE3)00685 {00686     <span class="comment">// if a user function is defined, execute it</span>00687     <span class="keywordflow">if</span>(TimerIntFunc[TIMER3INPUTCAPTURE_INT])00688         TimerIntFunc[TIMER3INPUTCAPTURE_INT]();00689 }</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 + -