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

📄 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:   1

Command   : -ftimer.pcc
In-file   : timer.c
PPL-file  : timer.ppl
Para-file : -cF054780
            -yC:\NECTools32\DEV\
            -p
            -kfiln
            -zn
            timer.c
*/

    1 : /*
    2 : *******************************************************************************
    3 : **
    4 : **  This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
    5 : **  78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
    6 : **
    7 : **  Filename :  timer.c
    8 : **  Abstract :  This file implements a device driver for the timer module
    9 : **  Device :    uPD78F0547
   10 : **  Compiler:   NEC/CC78K0
   11 : **
   12 : *******************************************************************************
   13 : */
   14 : 
   15 : #pragma sfr
   16 : 
   17 : /*
   18 : *******************************************************************************
   19 : **  Include files
   20 : *******************************************************************************
   21 : */
   22 : 
   23 : 
   24 : /*
   25 : *******************************************************************************
   26 : **
   27 : **  This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
   28 : **  78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
   29 : **
   30 : **  Filename :  timer_config.h
   31 : **  Abstract :  This file implements a device driver for the timer module
   32 : **  Device :    uPD78F0547
   33 : **  Compiler:   NEC/CC78K0
   34 : **
   35 : *******************************************************************************
   36 : */
   37 : 
   38 : /*
   39 : *******************************************************************************
   40 : **  Case : Square wave output function
   41 : **
   42 : **  Description : Output squarewave
   43 : **
   44 : **  Setting : fprs = 8MHz
   45 : **  TM00 cycle = 0.003s, duty = 30%
   46 : **  TM01 cycle = 0.006s, duty = 60%



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

   47 : **  TM50 cycle = 0.002048s, duty = 40%
   48 : **  TM51 cycle = 0.002048s, duty = 80%
   49 : **  TMH0 cycle = 0.005s, duty = 25%
   50 : **  TMH1 cycle = 0.01s, duty = 50%
   51 : **  
   52 : *******************************************************************************
   53 : */
   54 : 
   55 : 
   56 : /*
   57 : *******************************************************************************
   58 : **
   59 : **  This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
   60 : **  78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
   61 : **
   62 : **  Filename :  timer.h
   63 : **  Abstract :  This file implements a device driver for the timer module
   64 : **  Device :    uPD78F0547
   65 : **  Compiler:   NEC/CC78K0
   66 : **
   67 : *******************************************************************************
   68 : */
   69 : 
   70 : 
   71 : #define _TIMERMACRO_
   72 : 
   73 : /*
   74 : *******************************************************************************
   75 : **  Register bit define
   76 : *******************************************************************************
   77 : */
   78 : 
   79 : /* TM0n register bit define */
   80 : 
   81 : /* TM0n register TMC0n */
   82 : #define TM0n_TMC0n_Operation    0x0c
   83 :         #define TM0n_TMC0n_Operation_Disable    0x00
   84 :         #define TM0n_TMC0n_Operation_FreeRunning        0x04
   85 :         #define TM0n_TMC0n_Operation_ClearByTI00nEdge   0x08
   86 :         #define TM0n_TMC0n_Operation_ClearByMatchCR00n  0x0c
   87 : 
   88 : #define TM0n_TMC0n_Reverse      0x02
   89 :         #define TM0n_TMC0n_Reverse_ByMatchCR00n 0x00
   90 :         #define TM0n_TMC0n_Reverse_ByMatchCR00nAndTI00nInput    0x02
   91 : 
   92 : #define TM0n_TMC0n_OverflowFlag 0x01
   93 : 
   94 : /* TM0n register CRC0n */
   95 : #define TM0n_CRC0n_CR01nMode    0x04
   96 :         #define TM0n_CRC0n_CR01nMode_Compare    0x00
   97 :         #define TM0n_CRC0n_CR01nMode_Capture    0x04
   98 : 
   99 : #define TM0n_CRC0n_CR00nTrigger 0x02
  100 :         #define TM0n_CRC0n_CR00nTrigger_TI01nEdge       0x00
  101 :         #define TM0n_CRC0n_CR00nTrigger_TI00nEdgeReverse        0x02
  102 : 



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

  103 : #define TM0n_CRC0n_CR00nMode    0x01
  104 :         #define TM0n_CRC0n_CR00nMode_Compare    0x00
  105 :         #define TM0n_CRC0n_CR00nMode_Capture    0x01
  106 : 
  107 : /* TM0n register TOC0n */
  108 : #define TM0n_TOC0n_OneshotSoftTrigger   0x40    /* write only */
  109 : 
  110 : #define TM0n_TOC0n_OneshotMode  0x20
  111 :         #define TM0n_TOC0n_OneshotMode_Successive       0x00
  112 :         #define TM0n_TOC0n_OneshotMode_Oneshot  0x20
  113 : 
  114 : #define TM0n_TOC0n_ReverseTO0nByCR01n   0x10
  115 :         #define TM0n_TOC0n_ReverseTO0nByCR01n_Disable   0x00
  116 :         #define TM0n_TOC0n_ReverseTO0nByCR01n_Enable    0x10
  117 : 
  118 : #define TM0n_TOC0n_TO0nOutStatus        0x0C
  119 :         #define TM0n_TOC0n_TO0nOut_NoChange     0x00
  120 :         #define TM0n_TOC0n_TO0nOut_Clear0       0x04
  121 :         #define TM0n_TOC0n_TO0nOut_Set1 0x08
  122 :         #define TM0n_TOC0n_TO0nOut_Prohibited   0x0C
  123 : 
  124 : #define TM0n_TOC0n_TO0nReverseByCR00n   0x02
  125 :         #define TM0n_TOC0n_TO0nReverseByCR00n_Disable   0x00
  126 :         #define TM0n_TOC0n_TO0nReverseByCR00n_Enable    0x02
  127 : 
  128 : #define TM0n_TOC0n_TO0nOutControl       0x01
  129 :         #define TM0n_TOC0n_TO0nOut_Disable      0x00
  130 :         #define TM0n_TOC0n_TO0nOut_Enable       0x01
  131 : 
  132 : /* TM0n register PRM0n */
  133 : #define TM0n_PRM0n_TI01nEdge    0xc0
  134 :         #define TM0n_PRM0n_TI01nEdge_Falling    0x00
  135 :         #define TM0n_PRM0n_TI01nEdge_Rising     0x40
  136 :         #define TM0n_PRM0n_TI01nEdge_Prohibited 0x80
  137 :         #define TM0n_PRM0n_TI01nEdge_Both       0xc0
  138 : 
  139 : #define TM0n_PRM0n_TI00nEdge    0x30
  140 :         #define TM0n_PRM0n_TI00nEdge_Falling    0x00
  141 :         #define TM0n_PRM0n_TI00nEdge_Rising     0x10
  142 :         #define TM0n_PRM0n_TI00nEdge_Prohibited 0x20
  143 :         #define TM0n_PRM0n_TI00nEdge_Both       0x30
  144 : 
  145 : #define TM0n_PRM0n_CountClock   0x03
  146 :         #define TM0n_PRM0n_CountClock_Internal0 0x00    /* TM00 = fprs, TM00 = fprs */
  147 :         #define TM0n_PRM0n_CountClock_Internal1 0x01    /* TM00 = fprs/2^2, TM00 = fprs/2^4 */
  148 :         #define TM0n_PRM0n_CountClock_Internal2 0x02    /* TM00 = fprs/2^8, TM00 = fprs/2^6 */
  149 :         #define TM0n_PRM0n_CountClock_TI00nEdge 0x03
  150 : 
  151 : /* TM5n register bit define */
  152 : 
  153 : /* TM5n register TCL5n */
  154 : #define TM5n_TCL5n_CountCloc    0x07
  155 :         #define TM5n_TCL5n_CountClock_TI5nFalling       0x00
  156 :         #define TM5n_TCL5n_CountClock_TI5nRising        0x01
  157 :         #define TM5n_TCL5n_CountClock_Internal0 0x02    /* TM50 = fprs, TM51 = fprs */
  158 :         #define TM5n_TCL5n_CountClock_Internal1 0x03    /* TM50 = fprs/2, TM51 = fprs/2 */



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

  159 :         #define TM5n_TCL5n_CountClock_Internal2 0x04    /* TM50 = fprs/2^2, TM51 = fprs/2^4 */
  160 :         #define TM5n_TCL5n_CountClock_Internal3 0x05    /* TM50 = fprs/2^6, TM51 = fprs/2^6 */
  161 :         #define TM5n_TCL5n_CountClock_Internal4 0x06    /* TM50 = fprs/2^8, TM51 = fprs/2^8 */
  162 :         #define TM5n_TCL5n_CountClock_Internal5 0x07    /* TM50 = fprs/2^13, TM51 = fprs/2^12 */
  163 : 
  164 : /* TM5n register TMC5n */
  165 : #define TM5n_TMC5n_Operation    0x80
  166 :         #define TM5n_TMC5n_Operation_Disable    0x00
  167 :         #define TM5n_TMC5n_Operation_Start      0x80
  168 : 
  169 : #define TM5n_TMC5n_Mode 0x40
  170 :         #define TM5n_TMC5n_Mode_ClearByMatchCR5n        0x00
  171 :         #define TM5n_TMC5n_Mode_PWMFreeRunning  0x40
  172 : 
  173 : #define TM5n_TMC5n_OutPutStatus 0x0C
  174 :         #define TM5n_TMC5n_OutPut_NoChange      0x00
  175 :         #define TM5n_TMC5n_OutPut_Clear0        0x04
  176 :         #define TM5n_TMC5n_OutPut_Set1  0x08
  177 :         #define TM5n_TMC5n_OutPut_Prohibited    0x0C
  178 : 
  179 : #define TM5n_TMC5n_OutPutActiveLevel    0x02
  180 :         #define TM5n_TMC5n_OutPut_NoInversionActiveHigh 0x00
  181 :         #define TM5n_TMC5n_OutPut_InversionActiveLow    0x02
  182 : 
  183 : #define TM5n_TMC5n_OutPutControl        0x01
  184 :         #define TM5n_TMC5n_OutPut_Disable       0x00
  185 :         #define TM5n_TMC5n_OutPut_Enable        0x01
  186 : 
  187 : /* TMHn register bit define */
  188 : 
  189 : /* TMHn register TMHMDn */
  190 : #define TMHn_TMHMDn_Operation   0x80
  191 :         #define TMHn_TMHMDn_Operation_Stop      0x00
  192 :         #define TMHn_TMHMDn_Operation_Enable    0x80
  193 : 
  194 : #define TMHn_TMHMDn_CountClock  0x70
  195 :         #define TMHn_TMHMDn_CountClock_Internal0        0x00    /* TMH0 = fprs, TMH1 = fprs */
  196 :         #define TMHn_TMHMDn_CountClock_Internal1        0x10    /* TMH0 = fprs/2, TMH1 = fprs/2 */
  197 :         #define TMHn_TMHMDn_CountClock_Internal2        0x20    /* TMH0 = fprs/2^2, TMH1 = fprs/2^4 */
  198 :         #define TMHn_TMHMDn_CountClock_Internal3        0x30    /* TMH0 = fprs/2^6, TMH1 = fprs/2^6 */
  199 :         #define TMHn_TMHMDn_CountClock_Internal4        0x40    /* TMH0 = fprs/2^8, TMH1 = fprs/2^8 */
  200 :         #define TMHn_TMHMDn_CountClock_Internal5        0x50    /* TMH0 = fprs/2^13, TMH1 = frl/2^7 */
  201 :         #define TMHn_TMHMDn_CountClock_Internal6        0x60    /* TMH0 = fprs/2^13, TMH1 = frl/2^9 */
  202 :         #define TMHn_TMHMDn_CountClock_Internal7        0x70    /* TMH0 = fprs/2^13, TMH1 = frl */
  203 : 
  204 : #define TMHn_TMHMDn_Mode        0x0c
  205 :         #define TMHn_TMHMDn_Mode_Interval       0x00
  206 :         #define TMHn_TMHMDn_Mode_Carrier        0x04
  207 :         #define TMHn_TMHMDn_Mode_PWM    0x08
  208 : 
  209 : #define TMHn_TMHMDn_Level_Low   0x00
  210 : #define TMHn_TMHMDn_Level_High  0x02
  211 : 
  212 : #define TMHn_TMHMDn_OutPut_Disable      0x00
  213 : #define TMHn_TMHMDn_Output_Enable       0x01
  214 : 



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

  215 : /* TMHn register TMCYC1(TMH1 only) */
  216 : #define TMHn_TMCYC1_Remote      0x06
  217 :         #define TMHn_TMCYC1_Remote_Low  0x00
  218 :         #define TMHn_TMCYC1_Remote_High 0x02
  219 :         #define TMHn_TMCYC1_Remote_Low2 0x04
  220 :         #define TMHn_TMCYC1_Remote_Carrier      0x06
  221 : 
  222 : #define TMHn_TMCYC1_CarrierStatus       0x01
  223 :         #define TMHn_TMCYC1_Carrier_Disable     0x00
  224 :         #define TMHn_TMCYC1_Carrier_Enable      0x01
  225 : 
  226 : 
  227 : 
  228 : 
  229 : #define _TIMERCFG_
  230 : 
  231 : /*
  232 : *******************************************************************************
  233 : **  User control macro define
  234 : *******************************************************************************
  235 : */
  236 : 
  237 : /*
  238 : ***************************************
  239 : **  TM00 configure
  240 : **
  241 : **  Please set operation mode here
  242 : ***************************************
  243 : */
  244 : /* if no use set nouse = 1, if use some function set function = 1 */ 
  245 : #define TM00_NotUse     0
  246 : #define TM00_Interval   0
  247 : #define TM00_ExternalEvent      0
  248 : #define TM00_SquareOut  0
  249 : #define TM00_PPGOut     1
  250 : #define TM00_OneshotOut 0
  251 : #define TM00_PulseMeasurement   0
  252 :         /* if no use some method of pulse measurement set method = 1 */ 
  253 :         #define TM00_Pulse_TI00nAndTI01nFreeRunning     0
  254 :         #define TM00_Pulse_TI00nFreeRunning     0
  255 :         #define TM00_Pulse_TI00nRestart 1
  256 :         
  257 : /* macro for setting of different functions */
  258 : 
  259 :         /*
  260 :         ***************************************
  261 :         **  TM00 PPG output
  262 :         **
  263 :         **  user set cycle = 0.003s, duty = 30%
  264 :         ***************************************
  265 :         */
  266 :         
  267 :         /* Count clock and compare value */
  268 :         /* Use register bit macro
  269 :                 TM0n_PRM0n_CountClock_Internal0 :       fprs    or
  270 :                 TM0n_PRM0n_CountClock_Internal1 :       fprs/2^2        or

⌨️ 快捷键说明

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