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

📄 timer.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 3 页
字号:
  302 : /* if no use set nouse = 1, if use some function set function = 1 */ 
  303 : #define TM01_NotUse     0
  304 : #define TM01_Interval   0
  305 : #define TM01_ExternalEvent      1
  306 : #define TM01_SquareOut  0
  307 : #define TM01_PPGOut     0
  308 : #define TM01_OneshotOut 0
  309 : #define TM01_PulseMeasurement   0
  310 :         /* if no use some method of pulse measurement set method = 1 */ 
  311 :         #define TM01_Pulse_TI00nAndTI01nFreeRunning     0
  312 :         #define TM01_Pulse_TI00nFreeRunning     1
  313 :         #define TM01_Pulse_TI00nRestart 0
  314 :         
  315 : /* macro for setting of different functions */
  316 : 
  317 :         /*
  318 :         ***************************************
  319 :         **  TM01 external event
  320 :         **
  321 :         **  user set valid edges = 10
  322 :         ***************************************
  323 :         */
  324 :         
  325 :         /* Count clock and compare value */



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

  326 :         /* Use register bit macro
  327 :                 TM0n_PRM0n_CountClock_TI00nEdge
  328 :                         TM0n_PRM0n_TI00nEdge_Falling    or
  329 :                         TM0n_PRM0n_TI01nEdge_Rising     or
  330 :                         TM0n_PRM0n_TI01nEdge_Both
  331 :         */
  332 :         #define TM01_Clock      TM0n_PRM0n_CountClock_TI00nEdge|                TM0n_PRM0n_TI00nEdge_Falling
  333 :         /* 
  334 :                 Value range :   0x0001 - 0xffff
  335 :                 Valid edges = CR00n_value + 2 : first time after start
  336 :                                           CR00n_value + 1 :     second time or later
  337 :                 Note :  Valid edge interspace must > 2 * count_clock.
  338 :         */
  339 :         #define TM01_CR00nValue 0x9
  340 :         #define TM01_CR01nValue 0xffff
  341 :         
  342 :         /* Register settings */
  343 :         #define TM01_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
  344 :         /* external count clock only*/
  345 :         #define TM01_PRM0nValue TM01_Clock
  346 :         #define TM01_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
  347 :         
  348 :         /* Interrupt settings */
  349 :         #define TM01_INTTM001   1
  350 :         #define TM01_INTTM011   0
  351 : 
  352 : 
  353 : /*
  354 : ***************************************
  355 : **  TM50 configure
  356 : **
  357 : **  Please set operation mode here
  358 : ***************************************
  359 : */
  360 : /* if no use set nouse = 1, if use some function set function = 1 */
  361 : #define TM50_NotUse     0
  362 : #define TM50_Interval   0
  363 : #define TM50_ExternalEvent      1
  364 : #define TM50_SquareOut  0
  365 : #define TM50_PWMOut     0
  366 : 
  367 : 
  368 :         /*
  369 :         ***************************************
  370 :         **  TM50 external event
  371 :         **
  372 :         **  user set valid edges = 10
  373 :         ***************************************
  374 :         */
  375 :         
  376 :         /* Count clock and compare value */
  377 :         /* Use register bit macro
  378 :                 TM5n_TCL5n_CountClock_TI5nFalling
  379 :                 TM5n_TCL5n_CountClock_TI5nRising
  380 :                 Note :  Please select the higher frequency you can,
  381 :                         so the precision will be higher.



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

  382 :         */
  383 :         #define TM50_Clock      TM5n_TCL5n_CountClock_TI5nFalling
  384 :         /* 
  385 :                 Value range :   0x00 - 0xff
  386 :                 Valid edges = CR5n_value + 1
  387 :         */
  388 :         #define TM50_CR5nValue  0x09
  389 :         
  390 :         /* Register settings */
  391 :         #define TM50_TCL5nValue TM50_Clock      /* external count clock only*/
  392 :         #define TM50_TMC5nValue TM5n_TMC5n_Operation_Start|                                                     TM5n_TMC5n_M
      : ode_ClearByMatchCR5n
  393 :         
  394 :         /* Interrupt settings */
  395 :         #define TM50_INTTM50    1
  396 : 
  397 : 
  398 : /*
  399 : ***************************************
  400 : **  TM51 configure
  401 : **
  402 : **  Please set operation mode here
  403 : ***************************************
  404 : */
  405 : /* if no use set nouse = 1, if use some function set function = 1 */
  406 : #define TM51_NotUse     0
  407 : #define TM51_Interval   0
  408 : #define TM51_ExternalEvent      1
  409 : #define TM51_SquareOut  0
  410 : #define TM51_PWMOut     0
  411 : 
  412 : 
  413 :         /*
  414 :         ***************************************
  415 :         **  TM51 external event
  416 :         **
  417 :         **  user set valid edges = 10
  418 :         ***************************************
  419 :         */
  420 :         
  421 :         /* Count clock and compare value */
  422 :         /* Use register bit macro
  423 :                 TM5n_TCL5n_CountClock_TI5nFalling
  424 :                 TM5n_TCL5n_CountClock_TI5nRising
  425 :                 Note :  Please select the higher frequency you can,
  426 :                         so the precision will be higher.
  427 :         */
  428 :         #define TM51_Clock      TM5n_TCL5n_CountClock_TI5nFalling
  429 :         /* 
  430 :                 Value range :   0x00 - 0xff
  431 :                 Valid edges = CR5n_value + 1
  432 :         */
  433 :         #define TM51_CR5nValue  0x09
  434 :         
  435 :         /* Register settings */
  436 :         #define TM51_TCL5nValue TM51_Clock      /* external count clock only*/



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

  437 :         #define TM51_TMC5nValue TM5n_TMC5n_Operation_Start|                                                     TM5n_TMC5n_M
      : ode_ClearByMatchCR5n
  438 :         
  439 :         /* Interrupt settings */
  440 :         #define TM51_INTTM51    1
  441 : 
  442 : 
  443 : /*
  444 : ***************************************
  445 : **  TMH0 configure
  446 : **
  447 : **  Please set operation mode here
  448 : ***************************************
  449 : */
  450 : /* if no use set nouse = 1, if use some function set function = 1 */
  451 : #define TMH0_NotUse     1
  452 : #define TMH0_Interval   0
  453 : #define TMH0_SquareOut  0
  454 : #define TMH0_PWMOut     0
  455 : 
  456 : 
  457 :         /* Interrupt settings */
  458 :         #define TMH0_INTTMH0    0
  459 : 
  460 : 
  461 : /*
  462 : ***************************************
  463 : **  TMH1 configure
  464 : **
  465 : **  Please set operation mode here
  466 : ***************************************
  467 : */
  468 : /* if no use set nouse = 1, if use some function set function = 1 */
  469 : #define TMH1_NotUse     0
  470 : #define TMH1_Interval   0
  471 : #define TMH1_SquareOut  1
  472 : #define TMH1_PWMOut     0
  473 : #define TMH1_CarrierOut 0
  474 : 
  475 : 
  476 :         /*
  477 :         ***************************************
  478 :         **  TMH1 square wave out
  479 :         **
  480 :         **  user set square width = 0.02s
  481 :         ***************************************
  482 :         */
  483 :         
  484 :         /* Count clock and compare value */
  485 :         /* Use register bit macro
  486 :                 TMHn_TMHMDn_CountClock_Internal0        :       fprs
  487 :                 TMHn_TMHMDn_CountClock_Internal1        :       fprs/2
  488 :                 TMHn_TMHMDn_CountClock_Internal2        :       fprs/2^4
  489 :                 TMHn_TMHMDn_CountClock_Internal3        :       fprs/2^6
  490 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^12
  491 :                 TMHn_TMHMDn_CountClock_Internal5        :       frl/2^7



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

  492 :                 TMHn_TMHMDn_CountClock_Internal6        :       frl/2^9
  493 :                 TMHn_TMHMDn_CountClock_Internal7        :       frl
  494 :                 Note :  Please select the higher frequency you can,
  495 :                         so the precision will be higher.
  496 :         */
  497 :         #define TMH1_Clock      TMHn_TMHMDn_CountClock_Internal4
  498 :         /* 
  499 :                 Value range :   0x00 - 0xfe
  500 :                 Square width = (CMP0n_value + 1) * count_clock
  501 :         */
  502 :         #define TMH1_CMP0nValue  0x27   /* User set 0.125s */
  503 :         
  504 :         /* Register settings */
  505 :         #define TMH1_TMHMDnValue        TMHn_TMHMDn_Operation_Enable|                                                       
      :     TMH1_Clock|                                                         TMHn_TMHMDn_Mode_Interval|                          
      :                                 /* Value selection
  506 :                                                                         TMHn_TMHMDn_Level_Low
  507 :                                                                         TMHn_TMHMDn_Level_High
  508 :                                                                 */                                                          
      :     TMHn_TMHMDn_Level_Low|                                                              TMHn_TMHMDn_Output_Enable
  509 :         
  510 :         /* Interrupt settings */
  511 :         #define TMH1_INTTMH1    0
  512 : 
  513 : 
  514 : 
  515 : 
  516 : /*
  517 : *******************************************************************************
  518 : **  MacroDefine
  519 : *******************************************************************************
  520 : */
  521 : 
  522 : 
  523 : /*
  524 : **-----------------------------------------------------------------------------
  525 : **
  526 : **  Abstract:
  527 : **      This function initializes TM00.
  528 : **
  529 : **  Parameters:
  530 : **      None
  531 : **   
  532 : **  Returns:
  533 : **      None
  534 : **
  535 : **-----------------------------------------------------------------------------
  536 : */
  537 : void TM00_Init(void)
  538 : {
  539 :         /*
  540 :                 TMC00 = TM0n_TMC0n_Operation_Disable;
  541 :         */
  542 : 
  543 :         PRM00 = TM00_PRM0nValue;
  544 : 



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

  545 : 
  546 :         CRC00 = TM00_CRC0nValue;
  547 : 
  548 : 
  549 : 
  550 :         CR000 = TM00_CR00nValue;
  551 : 
  552 : 
  553 :         CR010 = TM00_CR01nValue;
  554 : 
  555 :         /* TI000 and/or TI010 and/or TO00 pin setting */
  556 :         /* INTTM000 and/or INTTM010 priority */
  557 : }
  558 : /*
  559 : **-----------------------------------------------------------------------------
  560 : **
  561 : **  Abstract:
  562 : **      This function starts the TM00 counter. 
  563 : **
  564 : **  Parameters:
  565 : **      None
  566 : **
  567 : **  Returns:
  568 : **      None
  569 : **
  570 : **-----------------------------------------------------------------------------
  571 : */
  572 : void TM00_Enable(void)
  573 : {
  574 : 
  575 :         TMC00 = TM00_TMC0nValue;
  576 : 
  577 :         /* INTTM000 and/or INTTM010 enable */
  578 : }
  579 :                 
  580 : /*
  581 : **-----------------------------------------------------------------------------
  582 : **
  583 : **  Abstract:
  584 : **      This function stops the TM00 counter and clear the count register.
  585 : **
  586 : **  Parameters:
  587 : **      None
  588 : **
  589 : **  Returns:
  590 : **      None
  591 : **
  592 : **-----------------------------------------------------------------------------
  593 : */
  594 : void TM00_Disable(void)
  595 : {
  596 :         /* Use register bit macro
  597 :                 TM0n_TMC0n_Operation_Disable
  598 :         */
  599 :         TMC00 = TM0n_TMC0n_Operation_Disable;
  600 :         



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

  601 :         /* INTTM000 and/or INTTM010 disable */
  602 : }
  603 : 
  604 : 
  605 : 
  606 : /*
  607 : **-----------------------------------------------------------------------------
  608 : **

⌨️ 快捷键说明

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