📄 timer.ppl
字号:
338 : */
339 : #define TM01_Clock TM0n_PRM0n_CountClock_Internal2
340 : /*
341 : Value range : 0x0001 - 0xffff
342 : Interval time = (CR00n_value + 1) * count_clock
343 : */
344 : #define TM01_CR00nValue 0xf423
345 : #define TM01_CR01nValue 0xffff
346 :
347 : /* Register settings */
348 : #define TM01_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
349 : #define TM01_PRM0nValue TM01_Clock
350 : #define TM01_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
351 :
352 : /* Interrupt settings */
353 : #define TM01_INTTM001 1
354 : #define TM01_INTTM011 0
355 :
356 :
357 : /*
358 : ***************************************
359 : ** TM50 configure
360 : **
361 : ** Please set operation mode here
362 : ***************************************
363 : */
364 : /* if no use set nouse = 1, if use some function set function = 1 */
365 : #define TM50_NotUse 0
366 : #define TM50_Interval 1
367 : #define TM50_ExternalEvent 0
368 : #define TM50_SquareOut 0
369 : #define TM50_PWMOut 0
370 :
371 :
372 : /*
373 : ***************************************
374 : ** TM50 interval
375 : **
376 : ** user set interval time = 0.25s
377 : ***************************************
378 : */
379 :
380 : /* Count clock and compare value */
381 : /* Use register bit macro
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 8
*/
382 : TM5n_TCL5n_CountClock_TI5nFalling
383 : TM5n_TCL5n_CountClock_TI5nRising
384 : TM5n_TCL5n_CountClock_Internal0 : fprs
385 : TM5n_TCL5n_CountClock_Internal1 : fprs/2
386 : TM5n_TCL5n_CountClock_Internal2 : fprs/2^2
387 : TM5n_TCL5n_CountClock_Internal3 : fprs/2^6
388 : TM5n_TCL5n_CountClock_Internal4 : fprs/2^8
389 : TM5n_TCL5n_CountClock_Internal5 : fprs/2^13
390 : Note : Please select the higher frequency you can,
391 : so the precision will be higher.
392 : */
393 : #define TM50_Clock TM5n_TCL5n_CountClock_Internal5
394 : /*
395 : Value range : 0x00 - 0xff
396 : Interval time = (CR5n_value + 1) * count_clock
397 : */
398 : #define TM50_CR5nValue 0xf3
399 :
400 : /* Register settings */
401 : #define TM50_TCL5nValue TM50_Clock
402 : #define TM50_TMC5nValue TM5n_TMC5n_Operation_Start| TM5n_TMC5n_M
: ode_ClearByMatchCR5n
403 :
404 : /* Interrupt settings */
405 : #define TM50_INTTM50 1
406 :
407 :
408 : /*
409 : ***************************************
410 : ** TM51 configure
411 : **
412 : ** Please set operation mode here
413 : ***************************************
414 : */
415 : /* if no use set nouse = 1, if use some function set function = 1 */
416 : #define TM51_NotUse 0
417 : #define TM51_Interval 1
418 : #define TM51_ExternalEvent 0
419 : #define TM51_SquareOut 0
420 : #define TM51_PWMOut 0
421 :
422 :
423 : /*
424 : ***************************************
425 : ** TM51 interval
426 : **
427 : ** user set interval time = 0.125s
428 : ***************************************
429 : */
430 :
431 : /* Count clock and compare value */
432 : /* Use register bit macro
433 : TM5n_TCL5n_CountClock_TI5nFalling
434 : TM5n_TCL5n_CountClock_TI5nRising
435 : TM5n_TCL5n_CountClock_Internal0 : fprs
436 : TM5n_TCL5n_CountClock_Internal1 : fprs/2
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 9
*/
437 : TM5n_TCL5n_CountClock_Internal2 : fprs/2^4
438 : TM5n_TCL5n_CountClock_Internal3 : fprs/2^6
439 : TM5n_TCL5n_CountClock_Internal4 : fprs/2^8
440 : TM5n_TCL5n_CountClock_Internal5 : fprs/2^12
441 : Note : Please select the higher frequency you can,
442 : so the precision will be higher.
443 : */
444 : #define TM51_Clock TM5n_TCL5n_CountClock_Internal5
445 : /*
446 : Value range : 0x00 - 0xff
447 : Interval time = (CR5n_value + 1) * count_clock
448 : */
449 : #define TM51_CR5nValue 0xf3
450 :
451 : /* Register settings */
452 : #define TM51_TCL5nValue TM51_Clock
453 : #define TM51_TMC5nValue TM5n_TMC5n_Operation_Start| TM5n_TMC5n_M
: ode_ClearByMatchCR5n
454 :
455 : /* Interrupt settings */
456 : #define TM51_INTTM51 1
457 :
458 :
459 : /*
460 : ***************************************
461 : ** TMH0 configure
462 : **
463 : ** Please set operation mode here
464 : ***************************************
465 : */
466 : /* if no use set nouse = 1, if use some function set function = 1 */
467 : #define TMH0_NotUse 0
468 : #define TMH0_Interval 1
469 : #define TMH0_SquareOut 0
470 : #define TMH0_PWMOut 0
471 :
472 :
473 : /*
474 : ***************************************
475 : ** TMH0 interval
476 : **
477 : ** user set interval time = 0.03125s
478 : ***************************************
479 : */
480 :
481 : /* Count clock and compare value */
482 : /* Use register bit macro
483 : TMHn_TMHMDn_CountClock_Internal0 : fprs
484 : TMHn_TMHMDn_CountClock_Internal1 : fprs/2
485 : TMHn_TMHMDn_CountClock_Internal2 : fprs/2^2
486 : TMHn_TMHMDn_CountClock_Internal3 : fprs/2^6
487 : TMHn_TMHMDn_CountClock_Internal4 : fprs/2^10
488 : TMHn_TMHMDn_CountClock_Internal5 : TM50Output
489 : Note : Please select the higher frequency you can,
490 : so the precision will be higher.
491 : */
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 10
*/
492 : #define TMH0_Clock TMHn_TMHMDn_CountClock_Internal4
493 : /*
494 : Value range : 0x00 - 0xfe
495 : Interval time = (CMP0n_value + 1) * count_clock
496 : */
497 : #define TMH0_CMP0nValue 0xf3
498 :
499 : /* Register settings */
500 : #define TMH0_TMHMDnValue TMHn_TMHMDn_Operation_Enable|
: TMH0_Clock| TMHn_TMHMDn_Mode_Interval|
: TMHn_TMHMDn_OutPut_Disable
501 :
502 : /* Interrupt settings */
503 : #define TMH0_INTTMH0 1
504 :
505 :
506 : /*
507 : ***************************************
508 : ** TMH1 configure
509 : **
510 : ** Please set operation mode here
511 : ***************************************
512 : */
513 : /* if no use set nouse = 1, if use some function set function = 1 */
514 : #define TMH1_NotUse 0
515 : #define TMH1_Interval 1
516 : #define TMH1_SquareOut 0
517 : #define TMH1_PWMOut 0
518 : #define TMH1_CarrierOut 0
519 :
520 :
521 : /*
522 : ***************************************
523 : ** TMH1 interval
524 : **
525 : ** user set interval time = 0.125s
526 : ***************************************
527 : */
528 :
529 : /* Count clock and compare value */
530 : /* Use register bit macro
531 : TMHn_TMHMDn_CountClock_Internal0 : fprs
532 : TMHn_TMHMDn_CountClock_Internal1 : fprs/2
533 : TMHn_TMHMDn_CountClock_Internal2 : fprs/2^4
534 : TMHn_TMHMDn_CountClock_Internal3 : fprs/2^6
535 : TMHn_TMHMDn_CountClock_Internal4 : fprs/2^12
536 : TMHn_TMHMDn_CountClock_Internal5 : frl/2^7
537 : TMHn_TMHMDn_CountClock_Internal6 : frl/2^9
538 : TMHn_TMHMDn_CountClock_Internal7 : frl
539 : Note : Please select the higher frequency you can,
540 : so the precision will be higher.
541 : */
542 : #define TMH1_Clock TMHn_TMHMDn_CountClock_Internal4
543 : /*
544 : Value range : 0x00 - 0xfe
545 : Interval time = (CMP0n_value + 1) * count_clock
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 11
*/
546 : */
547 : #define TMH1_CMP0nValue 0xf3 /* User set 0.125s */
548 :
549 : /* Register settings */
550 : #define TMH1_TMHMDnValue TMHn_TMHMDn_Operation_Enable|
: TMH1_Clock| TMHn_TMHMDn_Mode_Interval|
: TMHn_TMHMDn_OutPut_Disable
551 :
552 : /* Interrupt settings */
553 : #define TMH1_INTTMH1 1
554 :
555 :
556 :
557 :
558 : /*
559 : *******************************************************************************
560 : ** MacroDefine
561 : *******************************************************************************
562 : */
563 :
564 :
565 : /*
566 : **-----------------------------------------------------------------------------
567 : **
568 : ** Abstract:
569 : ** This function initializes TM00.
570 : **
571 : ** Parameters:
572 : ** None
573 : **
574 : ** Returns:
575 : ** None
576 : **
577 : **-----------------------------------------------------------------------------
578 : */
579 : void TM00_Init(void)
580 : {
581 : /*
582 : TMC00 = TM0n_TMC0n_Operation_Disable;
583 : */
584 :
585 : PRM00 = TM00_PRM0nValue;
586 :
587 :
588 : CRC00 = TM00_CRC0nValue;
589 :
590 :
591 :
592 : CR000 = TM00_CR00nValue;
593 :
594 :
595 : CR010 = TM00_CR01nValue;
596 :
597 : /* TI000 and/or TI010 and/or TO00 pin setting */
598 : /* INTTM000 and/or INTTM010 priority */
599 : }
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 12
*/
600 : /*
601 : **-----------------------------------------------------------------------------
602 : **
603 : ** Abstract:
604 : ** This function starts the TM00 counter.
605 : **
606 : ** Parameters:
607 : ** None
608 : **
609 : ** Returns:
610 : ** None
611 : **
612 : **-----------------------------------------------------------------------------
613 : */
614 : void TM00_Enable(void)
615 : {
616 :
617 : TMC00 = TM00_TMC0nValue;
618 :
619 : /* INTTM000 and/or INTTM010 enable */
620 : }
621 :
622 : /*
623 : **-----------------------------------------------------------------------------
624 : **
625 : ** Abstract:
626 : ** This function stops the TM00 counter and clear the count register.
627 : **
628 : ** Parameters:
629 : ** None
630 : **
631 : ** Returns:
632 : ** None
633 : **
634 : **-----------------------------------------------------------------------------
635 : */
636 : void TM00_Disable(void)
637 : {
638 : /* Use register bit macro
639 : TM0n_TMC0n_Operation_Disable
640 : */
641 : TMC00 = TM0n_TMC0n_Operation_Disable;
642 :
643 : /* INTTM000 and/or INTTM010 disable */
644 : }
645 :
646 :
647 :
648 : /*
649 : **-----------------------------------------------------------------------------
650 : **
651 : ** Abstract:
652 : ** This function can initialize TM01_module.
653 : **
654 : ** Parameters:
655 : ** None
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 13
*/
656 : **
657 : ** Returns:
658 : ** None
659 : **
660 : **-----------------------------------------------------------------------------
661 : */
662 : void TM01_Init(void)
663 : {
664 : /*
665 : TMC01 = TM0n_TMC0n_Operation_Disable;
666 : */
667 :
668 : PRM01 = TM01_PRM0nValue;
669 :
670 :
671 : CRC01 = TM01_CRC0nValue;
672 :
673 :
674 :
675 : CR001 = TM01_CR00nValue;
676 :
677 :
678 : CR011 = TM01_CR01nValue;
679 :
680 : /* TI001 and/or TI011 and/or TO01 pin setting */
681 : /* INTTM001 and/or INTTM011 priority */
682 : }
683 : /*
684 : **-----------------------------------------------------------------------------
685 : **
686 : ** Abstract:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -