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

📄 main.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 2 页
字号:
  323 : ***************************************
  324 : */
  325 : /* if no use set nouse = 1, if use some function set function = 1 */ 



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

  326 : #define TM01_NotUse     0
  327 : #define TM01_Interval   0
  328 : #define TM01_ExternalEvent      1
  329 : #define TM01_SquareOut  0
  330 : #define TM01_PPGOut     0
  331 : #define TM01_OneshotOut 0
  332 : #define TM01_PulseMeasurement   0
  333 :         /* if no use some method of pulse measurement set method = 1 */ 
  334 :         #define TM01_Pulse_TI00nAndTI01nFreeRunning     0
  335 :         #define TM01_Pulse_TI00nFreeRunning     1
  336 :         #define TM01_Pulse_TI00nRestart 0
  337 :         
  338 : /* macro for setting of different functions */
  339 : 
  340 :         /*
  341 :         ***************************************
  342 :         **  TM01 external event
  343 :         **
  344 :         **  user set valid edges = 10
  345 :         ***************************************
  346 :         */
  347 :         
  348 :         /* Count clock and compare value */
  349 :         /* Use register bit macro
  350 :                 TM0n_PRM0n_CountClock_TI00nEdge
  351 :                         TM0n_PRM0n_TI00nEdge_Falling    or
  352 :                         TM0n_PRM0n_TI01nEdge_Rising     or
  353 :                         TM0n_PRM0n_TI01nEdge_Both
  354 :         */
  355 :         #define TM01_Clock      TM0n_PRM0n_CountClock_TI00nEdge|                TM0n_PRM0n_TI00nEdge_Falling
  356 :         /* 
  357 :                 Value range :   0x0001 - 0xffff
  358 :                 Valid edges = CR00n_value + 2 : first time after start
  359 :                                           CR00n_value + 1 :     second time or later
  360 :                 Note :  Valid edge interspace must > 2 * count_clock.
  361 :         */
  362 :         #define TM01_CR00nValue 0x9
  363 :         #define TM01_CR01nValue 0xffff
  364 :         
  365 :         /* Register settings */
  366 :         #define TM01_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
  367 :         /* external count clock only*/
  368 :         #define TM01_PRM0nValue TM01_Clock
  369 :         #define TM01_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
  370 :         
  371 :         /* Interrupt settings */
  372 :         #define TM01_INTTM001   1
  373 :         #define TM01_INTTM011   0
  374 : 
  375 : 
  376 : /*
  377 : ***************************************
  378 : **  TM50 configure
  379 : **
  380 : **  Please set operation mode here
  381 : ***************************************



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

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


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

  437 :         ***************************************
  438 :         **  TM51 external event
  439 :         **
  440 :         **  user set valid edges = 10
  441 :         ***************************************
  442 :         */
  443 :         
  444 :         /* Count clock and compare value */
  445 :         /* Use register bit macro
  446 :                 TM5n_TCL5n_CountClock_TI5nFalling
  447 :                 TM5n_TCL5n_CountClock_TI5nRising
  448 :                 Note :  Please select the higher frequency you can,
  449 :                         so the precision will be higher.
  450 :         */
  451 :         #define TM51_Clock      TM5n_TCL5n_CountClock_TI5nFalling
  452 :         /* 
  453 :                 Value range :   0x00 - 0xff
  454 :                 Valid edges = CR5n_value + 1
  455 :         */
  456 :         #define TM51_CR5nValue  0x09
  457 :         
  458 :         /* Register settings */
  459 :         #define TM51_TCL5nValue TM51_Clock      /* external count clock only*/
  460 :         #define TM51_TMC5nValue TM5n_TMC5n_Operation_Start|                                                     TM5n_TMC5n_M
      : ode_ClearByMatchCR5n
  461 :         
  462 :         /* Interrupt settings */
  463 :         #define TM51_INTTM51    1
  464 : 
  465 : 
  466 : /*
  467 : ***************************************
  468 : **  TMH0 configure
  469 : **
  470 : **  Please set operation mode here
  471 : ***************************************
  472 : */
  473 : /* if no use set nouse = 1, if use some function set function = 1 */
  474 : #define TMH0_NotUse     1
  475 : #define TMH0_Interval   0
  476 : #define TMH0_SquareOut  0
  477 : #define TMH0_PWMOut     0
  478 : 
  479 : 
  480 :         /* Interrupt settings */
  481 :         #define TMH0_INTTMH0    0
  482 : 
  483 : 
  484 : /*
  485 : ***************************************
  486 : **  TMH1 configure
  487 : **
  488 : **  Please set operation mode here
  489 : ***************************************
  490 : */
  491 : /* if no use set nouse = 1, if use some function set function = 1 */



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

  492 : #define TMH1_NotUse     0
  493 : #define TMH1_Interval   0
  494 : #define TMH1_SquareOut  1
  495 : #define TMH1_PWMOut     0
  496 : #define TMH1_CarrierOut 0
  497 : 
  498 : 
  499 :         /*
  500 :         ***************************************
  501 :         **  TMH1 square wave out
  502 :         **
  503 :         **  user set square width = 0.02s
  504 :         ***************************************
  505 :         */
  506 :         
  507 :         /* Count clock and compare value */
  508 :         /* Use register bit macro
  509 :                 TMHn_TMHMDn_CountClock_Internal0        :       fprs
  510 :                 TMHn_TMHMDn_CountClock_Internal1        :       fprs/2
  511 :                 TMHn_TMHMDn_CountClock_Internal2        :       fprs/2^4
  512 :                 TMHn_TMHMDn_CountClock_Internal3        :       fprs/2^6
  513 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^12
  514 :                 TMHn_TMHMDn_CountClock_Internal5        :       frl/2^7
  515 :                 TMHn_TMHMDn_CountClock_Internal6        :       frl/2^9
  516 :                 TMHn_TMHMDn_CountClock_Internal7        :       frl
  517 :                 Note :  Please select the higher frequency you can,
  518 :                         so the precision will be higher.
  519 :         */
  520 :         #define TMH1_Clock      TMHn_TMHMDn_CountClock_Internal4
  521 :         /* 
  522 :                 Value range :   0x00 - 0xfe
  523 :                 Square width = (CMP0n_value + 1) * count_clock
  524 :         */
  525 :         #define TMH1_CMP0nValue  0x27   /* User set 0.125s */
  526 :         
  527 :         /* Register settings */
  528 :         #define TMH1_TMHMDnValue        TMHn_TMHMDn_Operation_Enable|                                                       
      :     TMH1_Clock|                                                         TMHn_TMHMDn_Mode_Interval|                          
      :                                 /* Value selection
  529 :                                                                         TMHn_TMHMDn_Level_Low
  530 :                                                                         TMHn_TMHMDn_Level_High
  531 :                                                                 */                                                          
      :     TMHn_TMHMDn_Level_Low|                                                              TMHn_TMHMDn_Output_Enable
  532 :         
  533 :         /* Interrupt settings */
  534 :         #define TMH1_INTTMH1    0
  535 : 
  536 : 
  537 : 
  538 : 
  539 : 
  540 : #define _HDTIMER_
  541 : 
  542 : /*
  543 : *******************************************************************************
  544 : **  Function proto type



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

  545 : *******************************************************************************
  546 : */
  547 : 
  548 : 
  549 : void TM00_Init(void);
  550 : void TM00_Enable(void);
  551 : void TM00_Disable(void);
  552 : 
  553 : 
  554 : 
  555 : void TM01_Init(void);
  556 : void TM01_Enable(void);
  557 : void TM01_Disable(void);
  558 : 
  559 : 
  560 : 
  561 : void TM50_Init(void);
  562 : void TM50_Enable(void);
  563 : void TM50_Disable(void);
  564 : 
  565 : 
  566 : 
  567 : void TM51_Init(void);
  568 : void TM51_Enable(void);
  569 : void TM51_Disable(void);
  570 : 
  571 : 
  572 : 
  573 : 
  574 : 
  575 : void TMH1_Init(void);
  576 : void TMH1_Enable(void);
  577 : void TMH1_Disable(void);
  578 : 
  579 : 
  580 : 
  581 : /*
  582 : *******************************************************************************
  583 : **  MacroDefine
  584 : *******************************************************************************
  585 : */
  586 : 
  587 : /* the value for IMS and IXS */
  588 : #define  MEMORY_IMS_SET         0xCC
  589 : #define  MEMORY_IXS_SET         0x00
  590 : 
  591 : /*
  592 : **-----------------------------------------------------------------------------
  593 : **
  594 : **  Abstract:
  595 : **      main function
  596 : **
  597 : **  Parameters:
  598 : **      None
  599 : **
  600 : **  Returns:



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

  601 : **      None
  602 : **
  603 : **-----------------------------------------------------------------------------
  604 : */
  605 : void main( void )
  606 : {
  607 :         IMS = MEMORY_IMS_SET;
  608 :         IXS = MEMORY_IXS_SET;
  609 :         /* TODO. add user code */
  610 :         EI();
  611 :         
  612 :         PM5 = 0;
  613 :         
  614 :         TMH1_Init();
  615 :         P1.6 = 0;
  616 :         PM1.6 = 0;
  617 :         TMH1_Enable();
  618 :         TMMKH1 = 1;
  619 :         
  620 :         TM00_Init();
  621 :         PM0.0 = 1;
  622 :         TM00_Enable();
  623 :         TMMK000 = 0;
  624 :         
  625 :         TM01_Init();
  626 :         PM0.5 = 1;
  627 :         TM01_Enable();
  628 :         TMMK001 = 0;
  629 :         
  630 :         TM50_Init();
  631 :         PM1.7 = 1;
  632 :         TM50_Enable();
  633 :         TMMK50 = 0;
  634 :         
  635 :         TM51_Init();
  636 :         PM3.3 = 1;
  637 :         TM51_Enable();
  638 :         TMMK51 = 0;
  639 :         
  640 :         while(1){
  641 :                 ;
  642 :         }
  643 : }


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

⌨️ 快捷键说明

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