📄 timer.ppl
字号:
322 : /* if no use set nouse = 1, if use some function set function = 1 */
323 : #define TM01_NotUse 0
324 : #define TM01_Interval 0
325 : #define TM01_ExternalEvent 0
326 : #define TM01_SquareOut 0
327 : #define TM01_PPGOut 0
328 : #define TM01_OneshotOut 1
329 : #define TM01_PulseMeasurement 0
330 : /* if no use some method of pulse measurement set method = 1 */
331 : #define TM01_Pulse_TI00nAndTI01nFreeRunning 0
332 : #define TM01_Pulse_TI00nFreeRunning 0
333 : #define TM01_Pulse_TI00nRestart 1
334 :
335 : /* macro for setting of different functions */
336 :
337 : /*
338 : ***************************************
339 : ** TM01 oneshot output
340 : **
341 : ** user set delay = 0.02s, width = 0.01s
342 : ***************************************
343 : */
344 :
345 : /* Count clock and compare value */
346 : /* Use register bit macro
347 : TM0n_PRM0n_CountClock_Internal0 : fprs or
348 : TM0n_PRM0n_CountClock_Internal1 : fprs/2^4 or
349 : TM0n_PRM0n_CountClock_Internal2 : fprs/2^6 or
350 : TM0n_PRM0n_CountClock_TI00nEdge(Note : software trigger only)
351 : TM0n_PRM0n_TI00nEdge_Falling or
352 : TM0n_PRM0n_TI01nEdge_Rising or
353 : TM0n_PRM0n_TI01nEdge_Both
354 : Note : Please select the higher frequency you can,
355 : so the precision will be higher.
356 : */
357 : #define TM01_Clock TM0n_PRM0n_CountClock_Internal1
358 : /*
359 : Value range : 0x0001 - 0xffff
360 : Delay time = (CR01n_value + 1) * count_clock
361 : Pulse width = (CR00n_value - CR01n_value) * count_clock
362 : CR01n_value < CR00n_value
363 : */
364 : #define TM01_CR00nValue 0x3a97
365 : #define TM01_CR01nValue 0x270f
366 :
367 : /* Register settings */
368 : /* Value selection
369 : TM0n_TMC0n_Operation_FreeRunning : software trigger
370 : TM0n_TMC0n_Operation_ClearByTI00nEdge : External trigger
371 : */
372 : #define TM01_TMC0nValue TM0n_TMC0n_Operation_FreeRunning
373 : /* Note : If use external trigger, use internal count clock only */
374 : #define TM01_PRM0nValue TM01_Clock| /* Use register bit macro
375 : TM0n_PRM0n_CountClock_TI00nEdge
376 : TM0n_PRM0n_TI00nEdge_Falling or
377 : TM0n_PRM0n_TI01nEdge_Rising or
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 8
*/
378 : TM0n_PRM0n_TI01nEdge_Both
379 : Note : External trigger set only
380 : */ TM0n_PRM0n_T
: I00nEdge_Falling
381 : #define TM01_CRC0nValue TM0n_CRC0n_CR01nMode_Compare| TM0n_CRC0n_C
: R00nMode_Compare
382 : #define TM01_TOC0nValue TM0n_TOC0n_OneshotMode_Oneshot| TM0n_TOC0n_R
: everseTO0nByCR01n_Enable| /* Value selection
383 : TM0n_TOC0n_TO0nOut_NoChange
384 : TM0n_TOC0n_TO0nOut_Clear0
385 : TM0n_TOC0n_TO0nOut_Set1
386 : */ TM0n_TOC0n_T
: O0nOut_Clear0| TM0n_TOC0n_TO0nReverseByCR00n_Enable|
: TM0n_TOC0n_TO0nOut_Enable
387 :
388 : /* Interrupt settings */
389 : #define TM01_INTTM001 0
390 : #define TM01_INTTM011 0
391 :
392 :
393 : /*
394 : ***************************************
395 : ** TM50 configure
396 : **
397 : ** Please set operation mode here
398 : ***************************************
399 : */
400 : /* if no use set nouse = 1, if use some function set function = 1 */
401 : #define TM50_NotUse 1
402 : #define TM50_Interval 0
403 : #define TM50_ExternalEvent 0
404 : #define TM50_SquareOut 0
405 : #define TM50_PWMOut 0
406 :
407 :
408 : /* Interrupt settings */
409 : #define TM50_INTTM50 0
410 :
411 :
412 : /*
413 : ***************************************
414 : ** TM51 configure
415 : **
416 : ** Please set operation mode here
417 : ***************************************
418 : */
419 : /* if no use set nouse = 1, if use some function set function = 1 */
420 : #define TM51_NotUse 1
421 : #define TM51_Interval 0
422 : #define TM51_ExternalEvent 0
423 : #define TM51_SquareOut 0
424 : #define TM51_PWMOut 0
425 :
426 :
427 : /* Interrupt settings */
428 : #define TM51_INTTM51 0
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 9
*/
429 :
430 :
431 : /*
432 : ***************************************
433 : ** TMH0 configure
434 : **
435 : ** Please set operation mode here
436 : ***************************************
437 : */
438 : /* if no use set nouse = 1, if use some function set function = 1 */
439 : #define TMH0_NotUse 1
440 : #define TMH0_Interval 0
441 : #define TMH0_SquareOut 0
442 : #define TMH0_PWMOut 0
443 :
444 :
445 : /* Interrupt settings */
446 : #define TMH0_INTTMH0 0
447 :
448 :
449 : /*
450 : ***************************************
451 : ** TMH1 configure
452 : **
453 : ** Please set operation mode here
454 : ***************************************
455 : */
456 : /* if no use set nouse = 1, if use some function set function = 1 */
457 : #define TMH1_NotUse 1
458 : #define TMH1_Interval 0
459 : #define TMH1_SquareOut 0
460 : #define TMH1_PWMOut 0
461 : #define TMH1_CarrierOut 0
462 :
463 :
464 : /* Interrupt settings */
465 : #define TMH1_INTTMH1 0
466 :
467 :
468 :
469 :
470 : /*
471 : *******************************************************************************
472 : ** MacroDefine
473 : *******************************************************************************
474 : */
475 :
476 :
477 : /*
478 : **-----------------------------------------------------------------------------
479 : **
480 : ** Abstract:
481 : ** This function initializes TM00.
482 : **
483 : ** Parameters:
484 : ** None
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 10
*/
485 : **
486 : ** Returns:
487 : ** None
488 : **
489 : **-----------------------------------------------------------------------------
490 : */
491 : void TM00_Init(void)
492 : {
493 : /*
494 : TMC00 = TM0n_TMC0n_Operation_Disable;
495 : */
496 :
497 : PRM00 = TM00_PRM0nValue;
498 :
499 :
500 : CRC00 = TM00_CRC0nValue;
501 :
502 :
503 : TOC00 = TM00_TOC0nValue;
504 :
505 :
506 : CR000 = TM00_CR00nValue;
507 :
508 :
509 : CR010 = TM00_CR01nValue;
510 :
511 : /* TI000 and/or TI010 and/or TO00 pin setting */
512 : /* INTTM000 and/or INTTM010 priority */
513 : }
514 : /*
515 : **-----------------------------------------------------------------------------
516 : **
517 : ** Abstract:
518 : ** This function starts the TM00 counter.
519 : **
520 : ** Parameters:
521 : ** None
522 : **
523 : ** Returns:
524 : ** None
525 : **
526 : **-----------------------------------------------------------------------------
527 : */
528 : void TM00_Enable(void)
529 : {
530 :
531 : TMC00 = TM00_TMC0nValue;
532 :
533 : /* INTTM000 and/or INTTM010 enable */
534 : }
535 :
536 : /*
537 : **-----------------------------------------------------------------------------
538 : **
539 : ** Abstract:
540 : ** This function stops the TM00 counter and clear the count register.
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 11
*/
541 : **
542 : ** Parameters:
543 : ** None
544 : **
545 : ** Returns:
546 : ** None
547 : **
548 : **-----------------------------------------------------------------------------
549 : */
550 : void TM00_Disable(void)
551 : {
552 : /* Use register bit macro
553 : TM0n_TMC0n_Operation_Disable
554 : */
555 : TMC00 = TM0n_TMC0n_Operation_Disable;
556 :
557 : /* INTTM000 and/or INTTM010 disable */
558 : }
559 :
560 :
561 :
562 : /*
563 : **-----------------------------------------------------------------------------
564 : **
565 : ** Abstract:
566 : ** This function can initialize TM01_module.
567 : **
568 : ** Parameters:
569 : ** None
570 : **
571 : ** Returns:
572 : ** None
573 : **
574 : **-----------------------------------------------------------------------------
575 : */
576 : void TM01_Init(void)
577 : {
578 : /*
579 : TMC01 = TM0n_TMC0n_Operation_Disable;
580 : */
581 :
582 : PRM01 = TM01_PRM0nValue;
583 :
584 :
585 : CRC01 = TM01_CRC0nValue;
586 :
587 :
588 : TOC01 = TM01_TOC0nValue;
589 :
590 :
591 : CR001 = TM01_CR00nValue;
592 :
593 :
594 : CR011 = TM01_CR01nValue;
595 :
596 : /* TI001 and/or TI011 and/or TO01 pin setting */
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 12
*/
597 : /* INTTM001 and/or INTTM011 priority */
598 : }
599 : /*
600 : **-----------------------------------------------------------------------------
601 : **
602 : ** Abstract:
603 : ** This function start the TM01 counter.
604 : **
605 : ** Parameters:
606 : ** None
607 : **
608 : ** Returns:
609 : ** None
610 : **
611 : **-----------------------------------------------------------------------------
612 : */
613 : void TM01_Enable(void)
614 : {
615 :
616 : TMC01 = TM01_TMC0nValue;
617 :
618 : /* INTTM001 and/or INTTM011 enable */
619 : }
620 :
621 : /*
622 : **-----------------------------------------------------------------------------
623 : **
624 : ** Abstract:
625 : ** This fnction stop the TM01 module.
626 : **
627 : ** Parameters:
628 : ** None
629 : **
630 : ** Returns:
631 : ** None
632 : **
633 : **-----------------------------------------------------------------------------
634 : */
635 : void TM01_Disable(void)
636 : {
637 : /* Use register bit macro
638 : TM0n_TMC0n_Operation_Disable
639 : */
640 : TMC01 = TM0n_TMC0n_Operation_Disable;
641 :
642 : /* INTTM001 and/or INTTM011 disable */
643 : }
644 :
645 :
646 :
647 :
648 :
649 :
650 :
651 :
652 :
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 13
*/
/*
Target chip : uPD78F0547_80
Device file : V2.00
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -