📄 timerx8_8c-source.html
字号:
00318 <span class="comment">// clear output compare value B</span>00319 OCR1B = 0;00320 00321 }00322 <span class="preprocessor">#endif</span>00323 <span class="preprocessor"></span><a name="l00324"></a><a class="code" href="group__timerpwm.html#ga2">00324</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga2">timer1PWMOff</a>(<span class="keywordtype">void</span>)00325 {00326 <span class="comment">// turn off timer1 PWM mode</span>00327 cbi(TCCR1A,PWM11);00328 cbi(TCCR1A,PWM10);00329 <span class="comment">// set PWM1A/B (OutputCompare action) to none</span>00330 <a class="code" href="group__timerpwm.html#ga5">timer1PWMAOff</a>();00331 <a class="code" href="group__timerpwm.html#ga6">timer1PWMBOff</a>();00332 }00333 <a name="l00334"></a><a class="code" href="group__timerpwm.html#ga3">00334</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga3">timer1PWMAOn</a>(<span class="keywordtype">void</span>)00335 {00336 <span class="comment">// turn on channel A (OC1A) PWM output</span>00337 <span class="comment">// set OC1A as non-inverted PWM</span>00338 sbi(TCCR1A,COM1A1);00339 cbi(TCCR1A,COM1A0);00340 }00341 <a name="l00342"></a><a class="code" href="group__timerpwm.html#ga4">00342</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga4">timer1PWMBOn</a>(<span class="keywordtype">void</span>)00343 {00344 <span class="comment">// turn on channel B (OC1B) PWM output</span>00345 <span class="comment">// set OC1B as non-inverted PWM</span>00346 sbi(TCCR1A,COM1B1);00347 cbi(TCCR1A,COM1B0);00348 }00349 <a name="l00350"></a><a class="code" href="group__timerpwm.html#ga5">00350</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga5">timer1PWMAOff</a>(<span class="keywordtype">void</span>)00351 {00352 <span class="comment">// turn off channel A (OC1A) PWM output</span>00353 <span class="comment">// set OC1A (OutputCompare action) to none</span>00354 cbi(TCCR1A,COM1A1);00355 cbi(TCCR1A,COM1A0);00356 }00357 <a name="l00358"></a><a class="code" href="group__timerpwm.html#ga6">00358</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga6">timer1PWMBOff</a>(<span class="keywordtype">void</span>)00359 {00360 <span class="comment">// turn off channel B (OC1B) PWM output</span>00361 <span class="comment">// set OC1B (OutputCompare action) to none</span>00362 cbi(TCCR1A,COM1B1);00363 cbi(TCCR1A,COM1B0);00364 }00365 <a name="l00366"></a><a class="code" href="group__timerpwm.html#ga7">00366</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga7">timer1PWMASet</a>(u16 pwmDuty)00367 {00368 <span class="comment">// set PWM (output compare) duty for channel A</span>00369 <span class="comment">// this PWM output is generated on OC1A pin</span>00370 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span>00371 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span>00372 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span>00373 <span class="comment">//outp( (pwmDuty>>8), OCR1AH); // set the high 8bits of OCR1A</span>00374 <span class="comment">//outp( (pwmDuty&0x00FF), OCR1AL); // set the low 8bits of OCR1A</span>00375 OCR1A = pwmDuty;00376 }00377 <a name="l00378"></a><a class="code" href="group__timerpwm.html#ga8">00378</a> <span class="keywordtype">void</span> <a class="code" href="group__timerpwm.html#ga8">timer1PWMBSet</a>(u16 pwmDuty)00379 {00380 <span class="comment">// set PWM (output compare) duty for channel B</span>00381 <span class="comment">// this PWM output is generated on OC1B pin</span>00382 <span class="comment">// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM</span>00383 <span class="comment">// pwmDuty should be in the range 0-511 for 9bit PWM</span>00384 <span class="comment">// pwmDuty should be in the range 0-1023 for 10bit PWM</span>00385 <span class="comment">//outp( (pwmDuty>>8), OCR1BH); // set the high 8bits of OCR1B</span>00386 <span class="comment">//outp( (pwmDuty&0x00FF), OCR1BL); // set the low 8bits of OCR1B</span>00387 OCR1B = pwmDuty;00388 }00389 <span class="comment"></span>00390 <span class="comment">//! Interrupt handler for tcnt0 overflow interrupt</span><a name="l00391"></a><a class="code" href="timerx8_8c.html#a27">00391</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)00392 {00393 Timer0Reg0++; <span class="comment">// increment low-order counter</span>00394 00395 <span class="comment">// increment pause counter</span>00396 TimerPauseReg++;00397 00398 <span class="comment">// if a user function is defined, execute it too</span>00399 <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OVERFLOW_INT])00400 TimerIntFunc[TIMER0OVERFLOW_INT]();00401 }00402 <span class="comment"></span>00403 <span class="comment">//! Interrupt handler for tcnt1 overflow interrupt</span><a name="l00404"></a><a class="code" href="timerx8_8c.html#a28">00404</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1)00405 {00406 <span class="comment">// if a user function is defined, execute it</span>00407 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OVERFLOW_INT])00408 TimerIntFunc[TIMER1OVERFLOW_INT]();00409 }00410 00411 <span class="preprocessor">#ifdef TCNT2 // support timer2 only if it exists</span>00412 <span class="preprocessor"></span><span class="comment">//! Interrupt handler for tcnt2 overflow interrupt</span>00413 <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW2)00414 {00415 Timer2Reg0++; <span class="comment">// increment low-order counter</span>00416 00417 <span class="comment">// if a user function is defined, execute it</span>00418 <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OVERFLOW_INT])00419 TimerIntFunc[TIMER2OVERFLOW_INT]();00420 }00421 <span class="preprocessor">#endif</span>00422 <span class="preprocessor"></span>00423 <span class="preprocessor">#ifdef OCR0</span>00424 <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>00425 <span class="comment">//! Interrupt handler for OutputCompare0 match (OC0) interrupt</span>00426 <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)00427 {00428 <span class="comment">// if a user function is defined, execute it</span>00429 <span class="keywordflow">if</span>(TimerIntFunc[TIMER0OUTCOMPARE_INT])00430 TimerIntFunc[TIMER0OUTCOMPARE_INT]();00431 }00432 <span class="preprocessor">#endif</span>00433 <span class="preprocessor"></span><span class="comment"></span>00434 <span class="comment">//! Interrupt handler for CutputCompare1A match (OC1A) interrupt</span><a name="l00435"></a><a class="code" href="timerx8_8c.html#a29">00435</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1A)00436 {00437 <span class="comment">// if a user function is defined, execute it</span>00438 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREA_INT])00439 TimerIntFunc[TIMER1OUTCOMPAREA_INT]();00440 }00441 <span class="comment"></span>00442 <span class="comment">//! Interrupt handler for OutputCompare1B match (OC1B) interrupt</span><a name="l00443"></a><a class="code" href="timerx8_8c.html#a30">00443</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1B)00444 {00445 <span class="comment">// if a user function is defined, execute it</span>00446 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1OUTCOMPAREB_INT])00447 TimerIntFunc[TIMER1OUTCOMPAREB_INT]();00448 }00449 <span class="comment"></span>00450 <span class="comment">//! Interrupt handler for InputCapture1 (IC1) interrupt</span><a name="l00451"></a><a class="code" href="timerx8_8c.html#a31">00451</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE1)00452 {00453 <span class="comment">// if a user function is defined, execute it</span>00454 <span class="keywordflow">if</span>(TimerIntFunc[TIMER1INPUTCAPTURE_INT])00455 TimerIntFunc[TIMER1INPUTCAPTURE_INT]();00456 }00457 <span class="comment"></span>00458 <span class="comment">//! Interrupt handler for OutputCompare2A match (OC2A) interrupt</span><a name="l00459"></a><a class="code" href="timerx8_8c.html#a32">00459</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE2A)00460 {00461 <span class="comment">// if a user function is defined, execute it</span>00462 <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OUTCOMPARE_INT])00463 TimerIntFunc[TIMER2OUTCOMPARE_INT]();00464 }00465 <span class="comment"></span>00466 <span class="comment">//! Interrupt handler for OutputCompare2B match (OC2B) interrupt</span><a name="l00467"></a><a class="code" href="timerx8_8c.html#a33">00467</a> <span class="comment"></span>TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE2B)00468 {00469 <span class="comment">// if a user function is defined, execute it</span>00470 <span class="keywordflow">if</span>(TimerIntFunc[TIMER2OUTCOMPARE_INT])00471 TimerIntFunc[TIMER2OUTCOMPARE_INT]();00472 }</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by <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 + -