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

📄 main.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 3 页
字号:
  490 :         */
  491 :         #define TM51_CR5nValue  0xcc
  492 :         
  493 :         /* Register settings */
  494 :         #define TM51_TCL5nValue TM51_Clock      /* internal count clock only*/
  495 :         #define TM51_TMC5nValue TM5n_TMC5n_Operation_Start|                                                     TM5n_TMC5n_M
      : ode_PWMFreeRunning|                                                     /* Value selection
  496 :                                                                 TM5n_TMC5n_OutPut_NoChange
  497 :                                                                 TM5n_TMC5n_OutPut_Clear0
  498 :                                                                 TM5n_TMC5n_OutPut_Set1
  499 :                                                         */                                                      TM5n_TMC5n_O
      : utPut_Clear0|                                                   /* Value selection
  500 :                                                                 TM5n_TMC5n_OutPut_NoInversionActiveHigh
  501 :                                                                 TM5n_TMC5n_OutPut_InversionActiveLow
  502 :                                                         */                                                      TM5n_TMC5n_O
      : utPut_InversionActiveLow|                                                       TM5n_TMC5n_OutPut_Enable
  503 :                                                         
  504 :         /* Interrupt settings */
  505 :         #define TM51_INTTM51    0
  506 : 
  507 : 
  508 : /*
  509 : ***************************************
  510 : **  TMH0 configure
  511 : **
  512 : **  Please set operation mode here
  513 : ***************************************
  514 : */
  515 : /* if no use set nouse = 1, if use some function set function = 1 */
  516 : #define TMH0_NotUse     0
  517 : #define TMH0_Interval   0
  518 : #define TMH0_SquareOut  0
  519 : #define TMH0_PWMOut     1
  520 : 
  521 : 
  522 :         /*
  523 :         ***************************************
  524 :         **  TMH0 PWM out
  525 :         **
  526 :         **  user set cycle = 0.005s, duty = 25%
  527 :         ***************************************
  528 :         */
  529 :         
  530 :         /* Count clock and compare value */
  531 :         /* Use register bit macro
  532 :                 TMHn_TMHMDn_CountClock_Internal0        :       fprs
  533 :                 TMHn_TMHMDn_CountClock_Internal1        :       fprs/2
  534 :                 TMHn_TMHMDn_CountClock_Internal2        :       fprs/2^2
  535 :                 TMHn_TMHMDn_CountClock_Internal3        :       fprs/2^6
  536 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^10



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

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


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

  590 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^12
  591 :                 TMHn_TMHMDn_CountClock_Internal5        :       frl/2^7
  592 :                 TMHn_TMHMDn_CountClock_Internal6        :       frl/2^9
  593 :                 TMHn_TMHMDn_CountClock_Internal7        :       frl
  594 :                 Note :  Please select the higher frequency you can,
  595 :                         so the precision will be higher.
  596 :         */
  597 :         #define TMH1_Clock      TMHn_TMHMDn_CountClock_Internal5
  598 :         /* 
  599 :                 Value range :   0x00 - 0xfe
  600 :                 Pulse cycle = (CMP0n_value + 1) * count_clock
  601 :                 Duty = (CMP1n_value + 1) / (CMP0n_value + 1)
  602 :                 CMP1n_value < CMP0n_value
  603 :         */
  604 :         #define TMH1_CMP0nValue 0x12
  605 :         #define TMH1_CMP1nValue 0x9
  606 :         
  607 :         /* Register settings */
  608 :         #define TMH1_TMHMDnValue        TMHn_TMHMDn_Operation_Enable|                                                       
      :     TMH1_Clock|                                                         TMHn_TMHMDn_Mode_PWM|                               
      :                         /* Value selection
  609 :                                                                         TMHn_TMHMDn_Level_Low
  610 :                                                                         TMHn_TMHMDn_Level_High
  611 :                                                                 */                                                          
      :     TMHn_TMHMDn_Level_Low|                                                              TMHn_TMHMDn_Output_Enable
  612 :         
  613 :         /* Interrupt settings */
  614 :         #define TMH1_INTTMH1    0
  615 : 
  616 : 
  617 : 
  618 : 
  619 : 
  620 : #define _HDTIMER_
  621 : 
  622 : /*
  623 : *******************************************************************************
  624 : **  Function proto type
  625 : *******************************************************************************
  626 : */
  627 : 
  628 : 
  629 : void TM00_Init(void);
  630 : void TM00_Enable(void);
  631 : void TM00_Disable(void);
  632 : 
  633 : 
  634 : 
  635 : void TM01_Init(void);
  636 : void TM01_Enable(void);
  637 : void TM01_Disable(void);
  638 : 
  639 : 
  640 : 
  641 : void TM50_Init(void);
  642 : void TM50_Enable(void);



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

  643 : void TM50_Disable(void);
  644 : 
  645 : 
  646 : 
  647 : void TM51_Init(void);
  648 : void TM51_Enable(void);
  649 : void TM51_Disable(void);
  650 : 
  651 : 
  652 : 
  653 : void TMH0_Init(void);
  654 : void TMH0_Enable(void);
  655 : void TMH0_Disable(void);
  656 : 
  657 : 
  658 : 
  659 : void TMH1_Init(void);
  660 : void TMH1_Enable(void);
  661 : void TMH1_Disable(void);
  662 : 
  663 : 
  664 : 
  665 : /*
  666 : *******************************************************************************
  667 : **  MacroDefine
  668 : *******************************************************************************
  669 : */
  670 : 
  671 : /* the value for IMS and IXS */
  672 : #define  MEMORY_IMS_SET         0xCC
  673 : #define  MEMORY_IXS_SET         0x00
  674 : 
  675 : /*
  676 : **-----------------------------------------------------------------------------
  677 : **
  678 : **  Abstract:
  679 : **      main function
  680 : **
  681 : **  Parameters:
  682 : **      None
  683 : **
  684 : **  Returns:
  685 : **      None
  686 : **
  687 : **-----------------------------------------------------------------------------
  688 : */
  689 : void main( void )
  690 : {
  691 :         IMS = MEMORY_IMS_SET;
  692 :         IXS = MEMORY_IXS_SET;
  693 :         /* TODO. add user code */
  694 :         EI();
  695 :         
  696 :         TM00_Init();
  697 :         /* P01 as TO00 */
  698 :         P0.1 = 0;



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

  699 :         PM0.1 = 0;
  700 :         TM00_Enable();
  701 :         
  702 :         TM01_Init();
  703 :         /* P06 as TO01 */
  704 :         P0.6 = 0;
  705 :         PM0.6 = 0;
  706 :         TM01_Enable();
  707 :         
  708 :         TM50_Init();
  709 :         /* P17 as TO50 */
  710 :         P1.7 = 0;
  711 :         PM1.7 = 0;
  712 :         TM50_Enable();
  713 :         
  714 :         TM51_Init();
  715 :         /* P33 as TO51 */
  716 :         P3.3 = 0;
  717 :         PM3.3 = 0;
  718 :         TM51_Enable();
  719 :         
  720 :         TMH0_Init();
  721 :         /* P15 as TOH0 */
  722 :         P1.5 = 0;
  723 :         PM1.5 = 0;
  724 :         TMH0_Enable();
  725 :         
  726 :         TMH1_Init();
  727 :         /* P16 as TOH1 */
  728 :         P1.6 = 0;
  729 :         PM1.6 = 0;
  730 :         TMH1_Enable();
  731 :         
  732 :         while(1){
  733 :                 ;
  734 :         }
  735 : }


/*
 Target chip : uPD78F0547_80
 Device file : V2.00 
*/

⌨️ 快捷键说明

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