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

📄 main.ppl

📁 the timer control demo source for the NEC mcu
💻 PPL
📖 第 1 页 / 共 2 页
字号:



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

  269 : #define TM00_Interval   0
  270 : #define TM00_ExternalEvent      0
  271 : #define TM00_SquareOut  0
  272 : #define TM00_PPGOut     0
  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     1
  277 :         #define TM00_Pulse_TI00nFreeRunning     0
  278 :         #define TM00_Pulse_TI00nRestart 0
  279 :         
  280 : /* macro for setting of different functions */
  281 : 
  282 :         /* Interrupt settings */
  283 :         #define TM00_INTTM000   0
  284 :         #define TM00_INTTM010   0
  285 : 
  286 : 
  287 : /*
  288 : ***************************************
  289 : **  TM01 configure
  290 : **
  291 : **  Please set operation mode here
  292 : ***************************************
  293 : */
  294 : /* if no use set nouse = 1, if use some function set function = 1 */ 
  295 : #define TM01_NotUse     1
  296 : #define TM01_Interval   0
  297 : #define TM01_ExternalEvent      0
  298 : #define TM01_SquareOut  0
  299 : #define TM01_PPGOut     0
  300 : #define TM01_OneshotOut 0
  301 : #define TM01_PulseMeasurement   0
  302 :         /* if no use some method of pulse measurement set method = 1 */ 
  303 :         #define TM01_Pulse_TI00nAndTI01nFreeRunning     0
  304 :         #define TM01_Pulse_TI00nFreeRunning     1
  305 :         #define TM01_Pulse_TI00nRestart 0
  306 :         
  307 : /* macro for setting of different functions */
  308 : 
  309 :         /* Interrupt settings */
  310 :         #define TM01_INTTM001   0
  311 :         #define TM01_INTTM011   0
  312 : 
  313 : 
  314 : /*
  315 : ***************************************
  316 : **  TM50 configure
  317 : **
  318 : **  Please set operation mode here
  319 : ***************************************
  320 : */
  321 : /* if no use set nouse = 1, if use some function set function = 1 */
  322 : #define TM50_NotUse     1
  323 : #define TM50_Interval   0
  324 : #define TM50_ExternalEvent      0



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

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


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

  380 :         /* Interrupt settings */
  381 :         #define TM51_INTTM51    1
  382 : 
  383 : 
  384 : /*
  385 : ***************************************
  386 : **  TMH0 configure
  387 : **
  388 : **  Please set operation mode here
  389 : ***************************************
  390 : */
  391 : /* if no use set nouse = 1, if use some function set function = 1 */
  392 : #define TMH0_NotUse     1
  393 : #define TMH0_Interval   0
  394 : #define TMH0_SquareOut  0
  395 : #define TMH0_PWMOut     0
  396 : 
  397 : 
  398 :         /* Interrupt settings */
  399 :         #define TMH0_INTTMH0    0
  400 : 
  401 : 
  402 : /*
  403 : ***************************************
  404 : **  TMH1 configure
  405 : **
  406 : **  Please set operation mode here
  407 : ***************************************
  408 : */
  409 : /* if no use set nouse = 1, if use some function set function = 1 */
  410 : #define TMH1_NotUse     0
  411 : #define TMH1_Interval   0
  412 : #define TMH1_SquareOut  0
  413 : #define TMH1_PWMOut     0
  414 : #define TMH1_CarrierOut 1
  415 : 
  416 : 
  417 :         /*
  418 :         ***************************************
  419 :         **  TMH1 carrier out
  420 :         **
  421 :         **  user set cycle = , duty =
  422 :         ***************************************
  423 :         */
  424 :         
  425 :         /* Count clock and compare value */
  426 :         /* Use register bit macro
  427 :                 TMHn_TMHMDn_CountClock_Internal0        :       fprs
  428 :                 TMHn_TMHMDn_CountClock_Internal1        :       fprs/2
  429 :                 TMHn_TMHMDn_CountClock_Internal2        :       fprs/2^4
  430 :                 TMHn_TMHMDn_CountClock_Internal3        :       fprs/2^6
  431 :                 TMHn_TMHMDn_CountClock_Internal4        :       fprs/2^12
  432 :                 TMHn_TMHMDn_CountClock_Internal5        :       frl/2^7
  433 :                 TMHn_TMHMDn_CountClock_Internal6        :       frl/2^9
  434 :                 TMHn_TMHMDn_CountClock_Internal7        :       frl
  435 :                 Note :  Please select the higher frequency you can,



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

  436 :                         so the precision will be higher.
  437 :         */
  438 :         #define TMH1_Clock      TMHn_TMHMDn_CountClock_Internal3
  439 :         /* 
  440 :                 Value range :   0x00 - 0xff
  441 :                 Carrier cycle = (CMP0n_value + CMP1n_value + 2) * count_clock
  442 :                 Duty = (CMP1n_value + 1) / (CMP0n_value + CMP1n_value + 2)
  443 :         */
  444 :         #define TMH1_CMP0nValue 0x63
  445 :         #define TMH1_CMP1nValue 0x18
  446 :         
  447 :         /* Register settings */
  448 :         #define TMH1_TMHMDnValue        TMHn_TMHMDn_Operation_Enable|                                                       
      :     TMH1_Clock|                                                         TMHn_TMHMDn_Mode_Carrier|                           
      :                                 /* Value selection
  449 :                                                                         TMHn_TMHMDn_Level_Low
  450 :                                                                         TMHn_TMHMDn_Level_High
  451 :                                                                 */                                                          
      :     TMHn_TMHMDn_Output_Enable
  452 :         #define TMH1_TMCYC1Value        TMHn_TMCYC1_Remote_Carrier|                                                         
      :     TMHn_TMCYC1_Carrier_Enable
  453 :         
  454 :         /* Interrupt settings */
  455 :         #define TMH1_INTTMH1    0
  456 : 
  457 : 
  458 : 
  459 : 
  460 : 
  461 : #define _HDTIMER_
  462 : 
  463 : /*
  464 : *******************************************************************************
  465 : **  Function proto type
  466 : *******************************************************************************
  467 : */
  468 : 
  469 : 
  470 : 
  471 : 
  472 : 
  473 : 
  474 : 
  475 : 
  476 : void TM51_Init(void);
  477 : void TM51_Enable(void);
  478 : void TM51_Disable(void);
  479 : 
  480 : 
  481 : 
  482 : 
  483 : 
  484 : void TMH1_Init(void);
  485 : void TMH1_Enable(void);
  486 : void TMH1_Disable(void);
  487 : 



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

  488 : 
  489 : 
  490 : /*
  491 : *******************************************************************************
  492 : **  MacroDefine
  493 : *******************************************************************************
  494 : */
  495 : 
  496 : /* the value for IMS and IXS */
  497 : #define  MEMORY_IMS_SET         0xCC
  498 : #define  MEMORY_IXS_SET         0x00
  499 : 
  500 : /*
  501 : **-----------------------------------------------------------------------------
  502 : **
  503 : **  Abstract:
  504 : **      main function
  505 : **
  506 : **  Parameters:
  507 : **      None
  508 : **
  509 : **  Returns:
  510 : **      None
  511 : **
  512 : **-----------------------------------------------------------------------------
  513 : */
  514 : void main( void )
  515 : {
  516 :         IMS = MEMORY_IMS_SET;
  517 :         IXS = MEMORY_IXS_SET;
  518 :         /* TODO. add user code */
  519 :         EI();
  520 :         
  521 :         PM5 = 0;
  522 :         
  523 :         TMH1_Init();
  524 :         P1.6 = 0;
  525 :         PM1.6 = 0;
  526 :         TMH1_Enable();
  527 :         
  528 :         TM51_Init();
  529 :         TM51_Enable();
  530 :         TMMK51 = 0;
  531 :         
  532 :         while(1){
  533 :                 ;
  534 :         }
  535 : }


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

⌨️ 快捷键说明

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