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