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

📄 timer_user.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 3 页
字号:
  497 : **  Please set operation mode here
  498 : ***************************************
  499 : */
  500 : /* if no use set nouse = 1, if use some function set function = 1 */
  501 : #define TMH0_NotUse     0
  502 : #define TMH0_Interval   0
  503 : #define TMH0_SquareOut  0
  504 : #define TMH0_PWMOut     1
  505 : 
  506 : 
  507 :         /*
  508 :         ***************************************
  509 :         **  TMH0 PWM out
  510 :         **
  511 :         **  user set cycle = 0.005s, duty = 25%
  512 :         ***************************************
  513 :         */
  514 :         
  515 :         /* Count clock and compare value */
  516 :         /* Use register bit macro
  517 :                 TMHn_TMHMDn_CountClock_Internal0        :       fprs
  518 :                 TMHn_TMHMDn_CountClock_Internal1        :       fprs/2
  519 :                 TMHn_TMHMDn_CountClock_Internal2        :       fprs/2^2
  520 :                 TMHn_TMHMDn_CountClock_Internal3        :       fprs/2^6
  521 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^10
  522 :                 TMHn_TMHMDn_CountClock_Internal5        :       TM50Output
  523 :                 Note :  Please select the higher frequency you can,
  524 :                         so the precision will be higher.
  525 :         */
  526 :         #define TMH0_Clock      TMHn_TMHMDn_CountClock_Internal4
  527 :         /* 
  528 :                 Value range :   0x00 - 0xfe
  529 :                 Pulse cycle = (CMP0n_value + 1) * count_clock
  530 :                 Duty = (CMP1n_value + 1) / (CMP0n_value + 1)
  531 :                 CMP1n_value < CMP0n_value
  532 :         */
  533 :         #define TMH0_CMP0nValue 0x26
  534 :         #define TMH0_CMP1nValue 0x09
  535 :         
  536 :         /* Register settings */



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

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


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

  590 :         #define TMH1_CMP1nValue 0x9
  591 :         
  592 :         /* Register settings */
  593 :         #define TMH1_TMHMDnValue        TMHn_TMHMDn_Operation_Enable|                                                       
      :     TMH1_Clock|                                                         TMHn_TMHMDn_Mode_PWM|                               
      :                         /* Value selection
  594 :                                                                         TMHn_TMHMDn_Level_Low
  595 :                                                                         TMHn_TMHMDn_Level_High
  596 :                                                                 */                                                          
      :     TMHn_TMHMDn_Level_Low|                                                              TMHn_TMHMDn_Output_Enable
  597 :         
  598 :         /* Interrupt settings */
  599 :         #define TMH1_INTTMH1    0
  600 : 
  601 : 
  602 : 
  603 : 
  604 : 
  605 : #define _HDTIMER_
  606 : 
  607 : /*
  608 : *******************************************************************************
  609 : **  Function proto type
  610 : *******************************************************************************
  611 : */
  612 : 
  613 : 
  614 : void TM00_Init(void);
  615 : void TM00_Enable(void);
  616 : void TM00_Disable(void);
  617 : 
  618 : 
  619 : 
  620 : void TM01_Init(void);
  621 : void TM01_Enable(void);
  622 : void TM01_Disable(void);
  623 : 
  624 : 
  625 : 
  626 : void TM50_Init(void);
  627 : void TM50_Enable(void);
  628 : void TM50_Disable(void);
  629 : 
  630 : 
  631 : 
  632 : void TM51_Init(void);
  633 : void TM51_Enable(void);
  634 : void TM51_Disable(void);
  635 : 
  636 : 
  637 : 
  638 : void TMH0_Init(void);
  639 : void TMH0_Enable(void);
  640 : void TMH0_Disable(void);
  641 : 
  642 : 



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

  643 : 
  644 : void TMH1_Init(void);
  645 : void TMH1_Enable(void);
  646 : void TMH1_Disable(void);
  647 : 
  648 : 
  649 : 
  650 : 
  651 : /*
  652 : *******************************************************************************
  653 : **
  654 : **  This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
  655 : **  78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
  656 : **
  657 : **  Filename :  timer_config.h
  658 : **  Abstract :  This file implements a device driver for the timer module
  659 : **  Device :    uPD78F0547
  660 : **  Compiler:   NEC/CC78K0
  661 : **
  662 : *******************************************************************************
  663 : */
  664 : 
  665 : /*
  666 : *******************************************************************************
  667 : **  Case : Square wave output function
  668 : **
  669 : **  Description : Output squarewave
  670 : **
  671 : **  Setting : fprs = 8MHz
  672 : **  TM00 cycle = 0.003s, duty = 30%
  673 : **  TM01 cycle = 0.006s, duty = 60%
  674 : **  TM50 cycle = 0.002048s, duty = 40%
  675 : **  TM51 cycle = 0.002048s, duty = 80%
  676 : **  TMH0 cycle = 0.005s, duty = 25%
  677 : **  TMH1 cycle = 0.01s, duty = 50%
  678 : **  
  679 : *******************************************************************************
  680 : */
  681 : 
  682 : 
  683 : /*
  684 : *******************************************************************************
  685 : **
  686 : **  This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
  687 : **  78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
  688 : **
  689 : **  Filename :  timer.h
  690 : **  Abstract :  This file implements a device driver for the timer module
  691 : **  Device :    uPD78F0547
  692 : **  Compiler:   NEC/CC78K0
  693 : **
  694 : *******************************************************************************
  695 : */
  696 : 
  697 : 
  698 : 



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

  699 : 
  700 : 
  701 : 
  702 : 
  703 : 
  704 : 
  705 : 
  706 : 
  707 : 
  708 : 
  709 : 
  710 : 
  711 : 
  712 : 
  713 : 
  714 : 
  715 : 
  716 : 
  717 : 
  718 : 
  719 : /*
  720 : *******************************************************************************
  721 : **  Include files
  722 : *******************************************************************************
  723 : */
  724 : 
  725 : /*
  726 : *******************************************************************************
  727 : **  MacroDefine
  728 : *******************************************************************************
  729 : */
  730 : 
  731 : 
  732 : 
  733 : 
  734 : 
  735 : 
  736 : 
  737 : 
  738 : 
  739 : 
  740 : 
  741 : 
  742 : 
  743 : 
  744 : 
  745 : 
  746 : 
  747 : 
  748 : 


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

⌨️ 快捷键说明

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