⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 4 页
字号:



/*
78K/0 Series C Compiler V3.60 Preprocess List                                                           Date: 9 Oct 2005 Page:  11
*/

  534 :         /* Interrupt settings */
  535 :         #define TMH0_INTTMH0    0
  536 : 
  537 : 
  538 : /*
  539 : ***************************************
  540 : **  TMH1 configure
  541 : **
  542 : **  Please set operation mode here
  543 : ***************************************
  544 : */
  545 : /* if no use set nouse = 1, if use some function set function = 1 */
  546 : #define TMH1_NotUse     0
  547 : #define TMH1_Interval   0
  548 : #define TMH1_SquareOut  0
  549 : #define TMH1_PWMOut     1
  550 : #define TMH1_CarrierOut 0
  551 : 
  552 : 
  553 :         /*
  554 :         ***************************************
  555 :         **  TMH1 PWM out
  556 :         **
  557 :         **  user set cycle = 0.01, duty = 50%
  558 :         ***************************************
  559 :         */
  560 :         
  561 :         /* Count clock and compare value */
  562 :         /* Use register bit macro
  563 :                 TMHn_TMHMDn_CountClock_Internal0        :       fprs
  564 :                 TMHn_TMHMDn_CountClock_Internal1        :       fprs/2
  565 :                 TMHn_TMHMDn_CountClock_Internal2        :       fprs/2^4
  566 :                 TMHn_TMHMDn_CountClock_Internal3        :       fprs/2^6
  567 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^12
  568 :                 TMHn_TMHMDn_CountClock_Internal5        :       frl/2^7
  569 :                 TMHn_TMHMDn_CountClock_Internal6        :       frl/2^9
  570 :                 TMHn_TMHMDn_CountClock_Internal7        :       frl
  571 :                 Note :  Please select the higher frequency you can,
  572 :                         so the precision will be higher.
  573 :         */
  574 :         #define TMH1_Clock      TMHn_TMHMDn_CountClock_Internal5
  575 :         /* 
  576 :                 Value range :   0x00 - 0xfe
  577 :                 Pulse cycle = (CMP0n_value + 1) * count_clock
  578 :                 Duty = (CMP1n_value + 1) / (CMP0n_value + 1)
  579 :                 CMP1n_value < CMP0n_value
  580 :         */
  581 :         #define TMH1_CMP0nValue 0x12
  582 :         #define TMH1_CMP1nValue 0x9
  583 :         
  584 :         /* Register settings */
  585 :         #define TMH1_TMHMDnValue        TMHn_TMHMDn_Operation_Enable|                                                       
      :     TMH1_Clock|                                                         TMHn_TMHMDn_Mode_PWM|                               
      :                         /* Value selection
  586 :                                                                         TMHn_TMHMDn_Level_Low
  587 :                                                                         TMHn_TMHMDn_Level_High



/*
78K/0 Series C Compiler V3.60 Preprocess List                                                           Date: 9 Oct 2005 Page:  12
*/

  588 :                                                                 */                                                          
      :     TMHn_TMHMDn_Level_Low|                                                              TMHn_TMHMDn_Output_Enable
  589 :         
  590 :         /* Interrupt settings */
  591 :         #define TMH1_INTTMH1    0
  592 : 
  593 : 
  594 : 
  595 : 
  596 : /*
  597 : *******************************************************************************
  598 : **  MacroDefine
  599 : *******************************************************************************
  600 : */
  601 : 
  602 : 
  603 : /*
  604 : **-----------------------------------------------------------------------------
  605 : **
  606 : **  Abstract:
  607 : **      This function initializes TM00.
  608 : **
  609 : **  Parameters:
  610 : **      None
  611 : **   
  612 : **  Returns:
  613 : **      None
  614 : **
  615 : **-----------------------------------------------------------------------------
  616 : */
  617 : void TM00_Init(void)
  618 : {
  619 :         /*
  620 :                 TMC00 = TM0n_TMC0n_Operation_Disable;
  621 :         */
  622 : 
  623 :         PRM00 = TM00_PRM0nValue;
  624 : 
  625 : 
  626 :         CRC00 = TM00_CRC0nValue;
  627 : 
  628 : 
  629 :         TOC00 = TM00_TOC0nValue;
  630 : 
  631 : 
  632 :         CR000 = TM00_CR00nValue;
  633 : 
  634 : 
  635 :         CR010 = TM00_CR01nValue;
  636 : 
  637 :         /* TI000 and/or TI010 and/or TO00 pin setting */
  638 :         /* INTTM000 and/or INTTM010 priority */
  639 : }
  640 : /*
  641 : **-----------------------------------------------------------------------------
  642 : **



/*
78K/0 Series C Compiler V3.60 Preprocess List                                                           Date: 9 Oct 2005 Page:  13
*/

  643 : **  Abstract:
  644 : **      This function starts the TM00 counter. 
  645 : **
  646 : **  Parameters:
  647 : **      None
  648 : **
  649 : **  Returns:
  650 : **      None
  651 : **
  652 : **-----------------------------------------------------------------------------
  653 : */
  654 : void TM00_Enable(void)
  655 : {
  656 : 
  657 :         TMC00 = TM00_TMC0nValue;
  658 : 
  659 :         /* INTTM000 and/or INTTM010 enable */
  660 : }
  661 :                 
  662 : /*
  663 : **-----------------------------------------------------------------------------
  664 : **
  665 : **  Abstract:
  666 : **      This function stops the TM00 counter and clear the count register.
  667 : **
  668 : **  Parameters:
  669 : **      None
  670 : **
  671 : **  Returns:
  672 : **      None
  673 : **
  674 : **-----------------------------------------------------------------------------
  675 : */
  676 : void TM00_Disable(void)
  677 : {
  678 :         /* Use register bit macro
  679 :                 TM0n_TMC0n_Operation_Disable
  680 :         */
  681 :         TMC00 = TM0n_TMC0n_Operation_Disable;
  682 :         
  683 :         /* INTTM000 and/or INTTM010 disable */
  684 : }
  685 : 
  686 : 
  687 : 
  688 : /*
  689 : **-----------------------------------------------------------------------------
  690 : **
  691 : **  Abstract:
  692 : **      This function can initialize TM01_module.
  693 : **
  694 : **  Parameters:
  695 : **      None
  696 : **   
  697 : **  Returns:
  698 : **      None



/*
78K/0 Series C Compiler V3.60 Preprocess List                                                           Date: 9 Oct 2005 Page:  14
*/

  699 : **
  700 : **-----------------------------------------------------------------------------
  701 : */
  702 : void TM01_Init(void)
  703 : {
  704 :         /*
  705 :                 TMC01 = TM0n_TMC0n_Operation_Disable;
  706 :         */
  707 : 
  708 :         PRM01 = TM01_PRM0nValue;
  709 : 
  710 : 
  711 :         CRC01 = TM01_CRC0nValue;
  712 : 
  713 : 
  714 :         TOC01 = TM01_TOC0nValue;
  715 : 
  716 : 
  717 :         CR001 = TM01_CR00nValue;
  718 : 
  719 : 
  720 :         CR011 = TM01_CR01nValue;
  721 : 
  722 :         /* TI001 and/or TI011 and/or TO01 pin setting */
  723 :         /* INTTM001 and/or INTTM011 priority */
  724 : }
  725 : /*
  726 : **-----------------------------------------------------------------------------
  727 : **
  728 : **  Abstract:
  729 : **      This function start the TM01 counter.
  730 : **
  731 : **  Parameters:
  732 : **      None
  733 : **
  734 : **  Returns:
  735 : **      None
  736 : **
  737 : **-----------------------------------------------------------------------------
  738 : */
  739 : void TM01_Enable(void)
  740 : {
  741 : 
  742 :         TMC01 = TM01_TMC0nValue;
  743 : 
  744 :         /* INTTM001 and/or INTTM011 enable */
  745 : }
  746 : 
  747 : /*
  748 : **-----------------------------------------------------------------------------
  749 : **
  750 : **  Abstract:
  751 : **      This fnction stop the TM01 module.
  752 : **
  753 : **  Parameters:
  754 : **      None



/*
78K/0 Series C Compiler V3.60 Preprocess List                                                           Date: 9 Oct 2005 Page:  15
*/

  755 : **
  756 : **  Returns:
  757 : **      None
  758 : **
  759 : **-----------------------------------------------------------------------------
  760 : */
  761 : void TM01_Disable(void)
  762 : {
  763 :         /* Use register bit macro
  764 :                 TM0n_TMC0n_Operation_Disable
  765 :         */
  766 :         TMC01 = TM0n_TMC0n_Operation_Disable;
  767 :         
  768 :         /* INTTM001 and/or INTTM011 disable */
  769 : }
  770 : 
  771 : 
  772 : 
  773 : /*
  774 : **-----------------------------------------------------------------------------
  775 : **
  776 : **  Abstract:
  777 : **      This function can initialize TM50_module.
  778 : **
  779 : **  Parameters:
  780 : **      None
  781 : **
  782 : **  Returns:
  783 : **      None
  784 : **
  785 : **-----------------------------------------------------------------------------
  786 : */
  787 : void TM50_Init(void)
  788 : {
  789 :         /*
  790 :                 TMC50 = TM5n_TMC5n_Operation_Disable;
  791 :         */
  792 : 
  793 :         TCL50 = TM50_TCL5nValue;
  794 : 
  795 : 
  796 :         CR50 = TM50_CR5nValue;
  797 : 
  798 :         /* TI50 or TO50 pin setting */
  799 :         /* INTTM50 priority */
  800 : }
  801 : 
  802 : /*
  803 : **-----------------------------------------------------------------------------
  804 : **
  805 : **  Abstract:
  806 : **      This function can start the TM50 counter.
  807 : **
  808 : **  Parameters:
  809 : **      None
  810 : **

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -