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

📄 timer128_8c-source.html

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