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

📄 main.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 3 页
字号:
  246 :         #define TMHn_TMCYC1_Carrier_Disable     0x00
  247 :         #define TMHn_TMCYC1_Carrier_Enable      0x01
  248 : 
  249 : 
  250 : 
  251 : 
  252 : #define _TIMERCFG_
  253 : 
  254 : /*
  255 : *******************************************************************************
  256 : **  User control macro define
  257 : *******************************************************************************
  258 : */
  259 : 
  260 : /*
  261 : ***************************************
  262 : **  TM00 configure
  263 : **
  264 : **  Please set operation mode here
  265 : ***************************************
  266 : */
  267 : /* if no use set nouse = 1, if use some function set function = 1 */ 
  268 : #define TM00_NotUse     0
  269 : #define TM00_Interval   0
  270 : #define TM00_ExternalEvent      0



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

  271 : #define TM00_SquareOut  0
  272 : #define TM00_PPGOut     1
  273 : #define TM00_OneshotOut 0
  274 : #define TM00_PulseMeasurement   0
  275 :         /* if no use some method of pulse measurement set method = 1 */ 
  276 :         #define TM00_Pulse_TI00nAndTI01nFreeRunning     0
  277 :         #define TM00_Pulse_TI00nFreeRunning     0
  278 :         #define TM00_Pulse_TI00nRestart 1
  279 :         
  280 : /* macro for setting of different functions */
  281 : 
  282 :         /*
  283 :         ***************************************
  284 :         **  TM00 PPG output
  285 :         **
  286 :         **  user set cycle = 0.003s, duty = 30%
  287 :         ***************************************
  288 :         */
  289 :         
  290 :         /* Count clock and compare value */
  291 :         /* Use register bit macro
  292 :                 TM0n_PRM0n_CountClock_Internal0 :       fprs    or
  293 :                 TM0n_PRM0n_CountClock_Internal1 :       fprs/2^2        or
  294 :                 TM0n_PRM0n_CountClock_Internal2 :       fprs/2^8        or
  295 :                 TM0n_PRM0n_CountClock_TI00nEdge
  296 :                         TM0n_PRM0n_TI00nEdge_Falling    or
  297 :                         TM0n_PRM0n_TI01nEdge_Rising     or
  298 :                         TM0n_PRM0n_TI01nEdge_Both
  299 :                 Note :  Please select the higher frequency you can,
  300 :                         so the precision will be higher.
  301 :         */
  302 :         #define TM00_Clock      TM0n_PRM0n_CountClock_Internal0
  303 :         /* 
  304 :                 Value range :   0x0001 - 0xffff
  305 :                 Pulse cycle = (CR00n_value + 1) * count_clock
  306 :                 Duty = (CR01n_value + 1) / (CR00n_value + 1)
  307 :                 CR01n_value < CR00n_value
  308 :         */
  309 :         #define TM00_CR00nValue 0x5dbf
  310 :         #define TM00_CR01nValue 0x1c1f
  311 :         
  312 :         /* Register settings */
  313 :         #define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
  314 :         #define TM00_PRM0nValue TM00_Clock
  315 :         #define TM00_CRC0nValue TM0n_CRC0n_CR01nMode_Compare|                                                   TM0n_CRC0n_C
      : R00nMode_Compare
  316 :         #define TM00_TOC0nValue TM0n_TOC0n_OneshotMode_Successive|                                                      TM0n
      : _TOC0n_ReverseTO0nByCR01n_Enable|                                                       /* Value selection
  317 :                                                                 TM0n_TOC0n_TO0nOut_NoChange
  318 :                                                                 TM0n_TOC0n_TO0nOut_Clear0
  319 :                                                                 TM0n_TOC0n_TO0nOut_Set1
  320 :                                                         */                                                      TM0n_TOC0n_T
      : O0nOut_Clear0|                                                  TM0n_TOC0n_TO0nReverseByCR00n_Enable|                       
      :                         TM0n_TOC0n_TO0nOut_Enable
  321 :         
  322 :         /* Interrupt settings */



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

  323 :         #define TM00_INTTM000   0
  324 :         #define TM00_INTTM010   0
  325 : 
  326 : 
  327 : /*
  328 : ***************************************
  329 : **  TM01 configure
  330 : **
  331 : **  Please set operation mode here
  332 : ***************************************
  333 : */
  334 : /* if no use set nouse = 1, if use some function set function = 1 */ 
  335 : #define TM01_NotUse     0
  336 : #define TM01_Interval   0
  337 : #define TM01_ExternalEvent      0
  338 : #define TM01_SquareOut  0
  339 : #define TM01_PPGOut     1
  340 : #define TM01_OneshotOut 0
  341 : #define TM01_PulseMeasurement   0
  342 :         /* if no use some method of pulse measurement set method = 1 */ 
  343 :         #define TM01_Pulse_TI00nAndTI01nFreeRunning     0
  344 :         #define TM01_Pulse_TI00nFreeRunning     0
  345 :         #define TM01_Pulse_TI00nRestart 1
  346 :         
  347 : /* macro for setting of different functions */
  348 : 
  349 :         /*
  350 :         ***************************************
  351 :         **  TM01 PPG output
  352 :         **
  353 :         **  user set cycle = 0.006s, duty = 60%
  354 :         ***************************************
  355 :         */
  356 :         
  357 :         /* Count clock and compare value */
  358 :         /* Use register bit macro
  359 :                 TM0n_PRM0n_CountClock_Internal0 :       fprs    or
  360 :                 TM0n_PRM0n_CountClock_Internal1 :       fprs/2^4        or
  361 :                 TM0n_PRM0n_CountClock_Internal2 :       fprs/2^6        or
  362 :                 TM0n_PRM0n_CountClock_TI00nEdge
  363 :                         TM0n_PRM0n_TI00nEdge_Falling    or
  364 :                         TM0n_PRM0n_TI01nEdge_Rising     or
  365 :                         TM0n_PRM0n_TI01nEdge_Both
  366 :                 Note :  Please select the higher frequency you can,
  367 :                         so the precision will be higher.
  368 :         */
  369 :         #define TM01_Clock      TM0n_PRM0n_CountClock_Internal0
  370 :         /* 
  371 :                 Value range :   0x0001 - 0xffff
  372 :                 Pulse cycle = (CR00n_value + 1) * count_clock
  373 :                 Duty = (CR01n_value + 1) / (CR00n_value + 1)
  374 :                 CR01n_value < CR00n_value
  375 :         */
  376 :         #define TM01_CR00nValue 0xbb7f
  377 :         #define TM01_CR01nValue 0x707f
  378 :         



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

  379 :         /* Register settings */
  380 :         #define TM01_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
  381 :         #define TM01_PRM0nValue TM01_Clock
  382 :         #define TM01_CRC0nValue TM0n_CRC0n_CR01nMode_Compare|                                                   TM0n_CRC0n_C
      : R00nMode_Compare
  383 :         #define TM01_TOC0nValue TM0n_TOC0n_OneshotMode_Successive|                                                      TM0n
      : _TOC0n_ReverseTO0nByCR01n_Enable|                                                       /* Value selection
  384 :                                                                 TM0n_TOC0n_TO0nOut_NoChange
  385 :                                                                 TM0n_TOC0n_TO0nOut_Clear0
  386 :                                                                 TM0n_TOC0n_TO0nOut_Set1
  387 :                                                         */                                                      TM0n_TOC0n_T
      : O0nOut_Clear0|                                                  TM0n_TOC0n_TO0nReverseByCR00n_Enable|                       
      :                         TM0n_TOC0n_TO0nOut_Enable
  388 :         
  389 :         /* Interrupt settings */
  390 :         #define TM01_INTTM001   0
  391 :         #define TM01_INTTM011   0
  392 : 
  393 : 
  394 : /*
  395 : ***************************************
  396 : **  TM50 configure
  397 : **
  398 : **  Please set operation mode here
  399 : ***************************************
  400 : */
  401 : /* if no use set nouse = 1, if use some function set function = 1 */
  402 : #define TM50_NotUse     0
  403 : #define TM50_Interval   0
  404 : #define TM50_ExternalEvent      0
  405 : #define TM50_SquareOut  0
  406 : #define TM50_PWMOut     1
  407 : 
  408 : 
  409 :         /*
  410 :         ***************************************
  411 :         **  TM50 PWM output
  412 :         **
  413 :         **  user set cycle = 0.002048s, duty = 40%
  414 :         ***************************************
  415 :         */
  416 :         
  417 :         /* Count clock and compare value */
  418 :         /* Use register bit macro
  419 :                 TM5n_TCL5n_CountClock_Internal0 :       fprs
  420 :                 TM5n_TCL5n_CountClock_Internal1 :       fprs/2
  421 :                 TM5n_TCL5n_CountClock_Internal2 :       fprs/2^2
  422 :                 TM5n_TCL5n_CountClock_Internal3 :       fprs/2^6
  423 :                 TM5n_TCL5n_CountClock_Internal4 :       fprs/2^8
  424 :                 TM5n_TCL5n_CountClock_Internal5 :       fprs/2^13
  425 :                 Note :  Please select the higher frequency you can,
  426 :                         so the precision will be higher.
  427 :         */
  428 :         #define TM50_Clock      TM5n_TCL5n_CountClock_Internal3
  429 :         /* 
  430 :                 Value range :   0x00 - 0xff



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

  431 :                 Pulse cycle = 256 * count_clock
  432 :                 Duty = CR5n_value / 256
  433 :         */
  434 :         #define TM50_CR5nValue 0x66
  435 :         
  436 :         /* Register settings */
  437 :         #define TM50_TCL5nValue TM50_Clock      /* internal count clock only*/
  438 :         #define TM50_TMC5nValue TM5n_TMC5n_Operation_Start|                                                     TM5n_TMC5n_M
      : ode_PWMFreeRunning|                                                     /* Value selection
  439 :                                                                 TM5n_TMC5n_OutPut_NoChange
  440 :                                                                 TM5n_TMC5n_OutPut_Clear0
  441 :                                                                 TM5n_TMC5n_OutPut_Set1
  442 :                                                         */                                                      TM5n_TMC5n_O
      : utPut_Clear0|                                                   /* Value selection
  443 :                                                                 TM5n_TMC5n_OutPut_NoInversionActiveHigh
  444 :                                                                 TM5n_TMC5n_OutPut_InversionActiveLow
  445 :                                                         */                                                      TM5n_TMC5n_O
      : utPut_InversionActiveLow|                                                       TM5n_TMC5n_OutPut_Enable
  446 : 
  447 :         /* Interrupt settings */
  448 :         #define TM50_INTTM50    0
  449 : 
  450 : 
  451 : /*
  452 : ***************************************
  453 : **  TM51 configure
  454 : **
  455 : **  Please set operation mode here
  456 : ***************************************
  457 : */
  458 : /* if no use set nouse = 1, if use some function set function = 1 */
  459 : #define TM51_NotUse     0
  460 : #define TM51_Interval   0
  461 : #define TM51_ExternalEvent      0
  462 : #define TM51_SquareOut  0
  463 : #define TM51_PWMOut     1
  464 : 
  465 : 
  466 :         /*
  467 :         ***************************************
  468 :         **  TM51 PWM output
  469 :         **
  470 :         **  user set cycle = 0.002048s, duty = 80%
  471 :         ***************************************
  472 :         */
  473 :         
  474 :         /* Count clock and compare value */
  475 :         /* Use register bit macro
  476 :                 TM5n_TCL5n_CountClock_Internal0 :       fprs
  477 :                 TM5n_TCL5n_CountClock_Internal1 :       fprs/2
  478 :                 TM5n_TCL5n_CountClock_Internal2 :       fprs/2^4
  479 :                 TM5n_TCL5n_CountClock_Internal3 :       fprs/2^6
  480 :                 TM5n_TCL5n_CountClock_Internal4 :       fprs/2^8
  481 :                 TM5n_TCL5n_CountClock_Internal5 :       fprs/2^12
  482 :                 Note :  Please select the higher frequency you can,
  483 :                         so the precision will be higher.



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

  484 :         */
  485 :         #define TM51_Clock      TM5n_TCL5n_CountClock_Internal3
  486 :         /* 
  487 :                 Value range :   0x00 - 0xff
  488 :                 Pulse cycle = 256 * count_clock
  489 :                 Duty = CR01n_value / 256

⌨️ 快捷键说明

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