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