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

📄 timer.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 2 页
字号:
  304 : 
  305 : 
  306 :         /* Interrupt settings */
  307 :         #define TM50_INTTM50    0
  308 : 
  309 : 
  310 : /*
  311 : ***************************************
  312 : **  TM51 configure
  313 : **
  314 : **  Please set operation mode here
  315 : ***************************************
  316 : */
  317 : /* if no use set nouse = 1, if use some function set function = 1 */
  318 : #define TM51_NotUse     0
  319 : #define TM51_Interval   1
  320 : #define TM51_ExternalEvent      0
  321 : #define TM51_SquareOut  0
  322 : #define TM51_PWMOut     0
  323 : 
  324 : 



/*
78K/0 Series C Compiler V3.70 Preprocess List                                                           Date:15 Jul 2007 Page:   7
*/

  325 :         /*
  326 :         ***************************************
  327 :         **  TM51 interval
  328 :         **
  329 :         **  user set interval time = 0.125s
  330 :         ***************************************
  331 :         */
  332 :         
  333 :         /* Count clock and compare value */
  334 :         /* Use register bit macro
  335 :                 TM5n_TCL5n_CountClock_TI5nFalling
  336 :                 TM5n_TCL5n_CountClock_TI5nRising
  337 :                 TM5n_TCL5n_CountClock_Internal0 :       fprs
  338 :                 TM5n_TCL5n_CountClock_Internal1 :       fprs/2
  339 :                 TM5n_TCL5n_CountClock_Internal2 :       fprs/2^4
  340 :                 TM5n_TCL5n_CountClock_Internal3 :       fprs/2^6
  341 :                 TM5n_TCL5n_CountClock_Internal4 :       fprs/2^8
  342 :                 TM5n_TCL5n_CountClock_Internal5 :       fprs/2^12
  343 :                 Note :  Please select the higher frequency you can,
  344 :                         so the precision will be higher.
  345 :         */
  346 :         #define TM51_Clock      TM5n_TCL5n_CountClock_Internal5
  347 :         /* 
  348 :                 Value range :   0x00 - 0xff
  349 :                 Interval time = (CR5n_value + 1) * count_clock
  350 :         */
  351 :         #define TM51_CR5nValue  0xf3
  352 :         
  353 :         /* Register settings */
  354 :         #define TM51_TCL5nValue TM51_Clock
  355 :         #define TM51_TMC5nValue TM5n_TMC5n_Operation_Start|                                                     TM5n_TMC5n_M
      : ode_ClearByMatchCR5n
  356 :         
  357 :         /* Interrupt settings */
  358 :         #define TM51_INTTM51    1
  359 : 
  360 : 
  361 : /*
  362 : ***************************************
  363 : **  TMH0 configure
  364 : **
  365 : **  Please set operation mode here
  366 : ***************************************
  367 : */
  368 : /* if no use set nouse = 1, if use some function set function = 1 */
  369 : #define TMH0_NotUse     1
  370 : #define TMH0_Interval   0
  371 : #define TMH0_SquareOut  0
  372 : #define TMH0_PWMOut     0
  373 : 
  374 : 
  375 :         /* Interrupt settings */
  376 :         #define TMH0_INTTMH0    0
  377 : 
  378 : 
  379 : /*



/*
78K/0 Series C Compiler V3.70 Preprocess List                                                           Date:15 Jul 2007 Page:   8
*/

  380 : ***************************************
  381 : **  TMH1 configure
  382 : **
  383 : **  Please set operation mode here
  384 : ***************************************
  385 : */
  386 : /* if no use set nouse = 1, if use some function set function = 1 */
  387 : #define TMH1_NotUse     0
  388 : #define TMH1_Interval   0
  389 : #define TMH1_SquareOut  0
  390 : #define TMH1_PWMOut     0
  391 : #define TMH1_CarrierOut 1
  392 : 
  393 : 
  394 :         /*
  395 :         ***************************************
  396 :         **  TMH1 carrier out
  397 :         **
  398 :         **  user set cycle = , duty =
  399 :         ***************************************
  400 :         */
  401 :         
  402 :         /* Count clock and compare value */
  403 :         /* Use register bit macro
  404 :                 TMHn_TMHMDn_CountClock_Internal0        :       fprs
  405 :                 TMHn_TMHMDn_CountClock_Internal1        :       fprs/2
  406 :                 TMHn_TMHMDn_CountClock_Internal2        :       fprs/2^4
  407 :                 TMHn_TMHMDn_CountClock_Internal3        :       fprs/2^6
  408 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^12
  409 :                 TMHn_TMHMDn_CountClock_Internal5        :       frl/2^7
  410 :                 TMHn_TMHMDn_CountClock_Internal6        :       frl/2^9
  411 :                 TMHn_TMHMDn_CountClock_Internal7        :       frl
  412 :                 Note :  Please select the higher frequency you can,
  413 :                         so the precision will be higher.
  414 :         */
  415 :         #define TMH1_Clock      TMHn_TMHMDn_CountClock_Internal3
  416 :         /* 
  417 :                 Value range :   0x00 - 0xff
  418 :                 Carrier cycle = (CMP0n_value + CMP1n_value + 2) * count_clock
  419 :                 Duty = (CMP1n_value + 1) / (CMP0n_value + CMP1n_value + 2)
  420 :         */
  421 :         #define TMH1_CMP0nValue 0x63
  422 :         #define TMH1_CMP1nValue 0x18
  423 :         
  424 :         /* Register settings */
  425 :         #define TMH1_TMHMDnValue        TMHn_TMHMDn_Operation_Enable|                                                       
      :     TMH1_Clock|                                                         TMHn_TMHMDn_Mode_Carrier|                           
      :                                 /* Value selection
  426 :                                                                         TMHn_TMHMDn_Level_Low
  427 :                                                                         TMHn_TMHMDn_Level_High
  428 :                                                                 */                                                          
      :     TMHn_TMHMDn_Output_Enable
  429 :         #define TMH1_TMCYC1Value        TMHn_TMCYC1_Remote_Carrier|                                                         
      :     TMHn_TMCYC1_Carrier_Enable
  430 :         
  431 :         /* Interrupt settings */



/*
78K/0 Series C Compiler V3.70 Preprocess List                                                           Date:15 Jul 2007 Page:   9
*/

  432 :         #define TMH1_INTTMH1    0
  433 : 
  434 : 
  435 : 
  436 : 
  437 : /*
  438 : *******************************************************************************
  439 : **  MacroDefine
  440 : *******************************************************************************
  441 : */
  442 : 
  443 : 
  444 : 
  445 : 
  446 : 
  447 : 
  448 : 
  449 : 
  450 : /*
  451 : **-----------------------------------------------------------------------------
  452 : **
  453 : **  Abstract:
  454 : **      This function Initializes TM51_module.
  455 : **
  456 : **  Parameters:
  457 : **      None
  458 : **
  459 : **  Returns:
  460 : **      None
  461 : **
  462 : **-----------------------------------------------------------------------------
  463 : */
  464 : void TM51_Init(void)
  465 : {
  466 :         /*
  467 :                 TMC51 = TM5n_TMC5n_Operation_Disable;
  468 :         */
  469 : 
  470 :         TCL51 = TM51_TCL5nValue;
  471 : 
  472 : 
  473 :         CR51 = TM51_CR5nValue;
  474 : 
  475 :         /* TI51 or TO51 pin setting */
  476 :         /* INTTM51 priority */
  477 : }
  478 : 
  479 : /*
  480 : **-----------------------------------------------------------------------------
  481 : **
  482 : **  Abstract:
  483 : **      This function starts the TM51 counter.
  484 : **
  485 : **  Parameters:
  486 : **      None
  487 : **



/*
78K/0 Series C Compiler V3.70 Preprocess List                                                           Date:15 Jul 2007 Page:  10
*/

  488 : **  Returns:
  489 : **      None
  490 : **
  491 : **-----------------------------------------------------------------------------
  492 : */
  493 : void TM51_Enable(void)
  494 : {
  495 : 
  496 :         TMC51 = TM51_TMC5nValue;
  497 : 
  498 :         /* INTTM51 enable */
  499 : }
  500 : 
  501 : /*
  502 : **-----------------------------------------------------------------------------
  503 : **
  504 : **  Abstract:
  505 : **      This function stops the TM51 counter and clear the count register.
  506 : **
  507 : **  Parameters:
  508 : **      None
  509 : **
  510 : **  Returns:
  511 : **      None
  512 : **
  513 : **-----------------------------------------------------------------------------
  514 : */
  515 : void TM51_Disable(void)
  516 : {
  517 :         /* Use register bit macro
  518 :                 TM5n_TMC5n_Operation_Disable
  519 :         */
  520 :         TMC51 = TM5n_TMC5n_Operation_Disable;
  521 :         
  522 :         /* INTTM51 disable */
  523 : }
  524 : 
  525 : 
  526 : 
  527 : 
  528 : 
  529 : /*
  530 : **-----------------------------------------------------------------------------
  531 : **
  532 : **  Abstract:
  533 : **      This function initializes TMH1_module.
  534 : **
  535 : **  Parameters:
  536 : **      None
  537 : **
  538 : **  Returns:
  539 : **      None
  540 : **
  541 : **-----------------------------------------------------------------------------
  542 : */
  543 : void TMH1_Init(void)



/*
78K/0 Series C Compiler V3.70 Preprocess List                                                           Date:15 Jul 2007 Page:  11
*/

  544 : {
  545 :         /*
  546 :                 TMHMD1 = TMHn_TMHMDn_Operation_Stop;
  547 :         */
  548 : 
  549 :         TMCYC1 = TMH1_TMCYC1Value;
  550 : 
  551 : 
  552 :         CMP01 = TMH1_CMP0nValue;
  553 : 
  554 : 
  555 :         CMP11 = TMH1_CMP1nValue;
  556 : 
  557 :         /* TOH1 pin setting */
  558 :         /* INTTMH1 priority */
  559 : }
  560 : 
  561 : /*
  562 : **-----------------------------------------------------------------------------
  563 : **
  564 : **  Abstract:
  565 : **      This function can start the TMH1 counter.
  566 : **
  567 : **  Parameters:
  568 : **      None
  569 : **
  570 : **  Returns:
  571 : **      None
  572 : **
  573 : **-----------------------------------------------------------------------------
  574 : */
  575 : void TMH1_Enable(void)
  576 : {
  577 : 
  578 :         TMHMD1 = TMH1_TMHMDnValue;
  579 : 
  580 :         /* INTTMH1 enable */
  581 : }
  582 : 
  583 : /*
  584 : **-----------------------------------------------------------------------------
  585 : **
  586 : **  Abstract:
  587 : **      This function can stop the TMH1 counter operation.
  588 : **
  589 : **  Parameters:
  590 : **      None
  591 : **
  592 : **  Returns:
  593 : **      None
  594 : **
  595 : **-----------------------------------------------------------------------------
  596 : */
  597 : void TMH1_Disable(void)
  598 : {
  599 :         /* Use register bit macro



/*
78K/0 Series C Compiler V3.70 Preprocess List                                                           Date:15 Jul 2007 Page:  12
*/

  600 :                 TMHn_TMHMDn_Operation_Stop
  601 :         */
  602 :         TMHMD1 = TMHn_TMHMDn_Operation_Stop;
  603 :         
  604 :         /* INTTMH1 disable */
  605 : }
  606 : 


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

⌨️ 快捷键说明

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