📄 main.ppl
字号:
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(Note : software trigger only)
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_Internal1
303 : /*
304 : Value range : 0x0001 - 0xffff
305 : Delay time = (CR01n_value + 1) * count_clock
306 : Pulse width = (CR00n_value - CR01n_value) * count_clock
307 : CR01n_value < CR00n_value
308 : */
309 : #define TM00_CR00nValue 0xea5f
310 : #define TM00_CR01nValue 0x4e1f
311 :
312 : /* Register settings */
313 : /* Value selection
314 : TM0n_TMC0n_Operation_FreeRunning : software trigger
315 : TM0n_TMC0n_Operation_ClearByTI00nEdge : External trigger
316 : */
317 : #define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByTI00nEdge
318 : /* Note : If use external trigger, use internal count clock only */
319 : #define TM00_PRM0nValue TM00_Clock| /* Use register bit macro
320 : TM0n_PRM0n_CountClock_TI00nEdge
321 : TM0n_PRM0n_TI00nEdge_Falling or
322 : TM0n_PRM0n_TI01nEdge_Rising or
323 : TM0n_PRM0n_TI01nEdge_Both
324 : Note : External trigger set only
325 : */ TM0n_PRM0n_T
: I00nEdge_Falling
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 7
*/
326 : #define TM00_CRC0nValue TM0n_CRC0n_CR01nMode_Compare| TM0n_CRC0n_C
: R00nMode_Compare
327 : #define TM00_TOC0nValue TM0n_TOC0n_OneshotMode_Oneshot| TM0n_TOC0n_R
: everseTO0nByCR01n_Enable| /* Value selection
328 : TM0n_TOC0n_TO0nOut_NoChange
329 : TM0n_TOC0n_TO0nOut_Clear0
330 : TM0n_TOC0n_TO0nOut_Set1
331 : */ TM0n_TOC0n_T
: O0nOut_Clear0| TM0n_TOC0n_TO0nReverseByCR00n_Enable|
: TM0n_TOC0n_TO0nOut_Enable
332 :
333 : /* Interrupt settings */
334 : #define TM00_INTTM000 0
335 : #define TM00_INTTM010 0
336 :
337 :
338 : /*
339 : ***************************************
340 : ** TM01 configure
341 : **
342 : ** Please set operation mode here
343 : ***************************************
344 : */
345 : /* if no use set nouse = 1, if use some function set function = 1 */
346 : #define TM01_NotUse 0
347 : #define TM01_Interval 0
348 : #define TM01_ExternalEvent 0
349 : #define TM01_SquareOut 0
350 : #define TM01_PPGOut 0
351 : #define TM01_OneshotOut 1
352 : #define TM01_PulseMeasurement 0
353 : /* if no use some method of pulse measurement set method = 1 */
354 : #define TM01_Pulse_TI00nAndTI01nFreeRunning 0
355 : #define TM01_Pulse_TI00nFreeRunning 0
356 : #define TM01_Pulse_TI00nRestart 1
357 :
358 : /* macro for setting of different functions */
359 :
360 : /*
361 : ***************************************
362 : ** TM01 oneshot output
363 : **
364 : ** user set delay = 0.02s, width = 0.01s
365 : ***************************************
366 : */
367 :
368 : /* Count clock and compare value */
369 : /* Use register bit macro
370 : TM0n_PRM0n_CountClock_Internal0 : fprs or
371 : TM0n_PRM0n_CountClock_Internal1 : fprs/2^4 or
372 : TM0n_PRM0n_CountClock_Internal2 : fprs/2^6 or
373 : TM0n_PRM0n_CountClock_TI00nEdge(Note : software trigger only)
374 : TM0n_PRM0n_TI00nEdge_Falling or
375 : TM0n_PRM0n_TI01nEdge_Rising or
376 : TM0n_PRM0n_TI01nEdge_Both
377 : Note : Please select the higher frequency you can,
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 8
*/
378 : so the precision will be higher.
379 : */
380 : #define TM01_Clock TM0n_PRM0n_CountClock_Internal1
381 : /*
382 : Value range : 0x0001 - 0xffff
383 : Delay time = (CR01n_value + 1) * count_clock
384 : Pulse width = (CR00n_value - CR01n_value) * count_clock
385 : CR01n_value < CR00n_value
386 : */
387 : #define TM01_CR00nValue 0x3a97
388 : #define TM01_CR01nValue 0x270f
389 :
390 : /* Register settings */
391 : /* Value selection
392 : TM0n_TMC0n_Operation_FreeRunning : software trigger
393 : TM0n_TMC0n_Operation_ClearByTI00nEdge : External trigger
394 : */
395 : #define TM01_TMC0nValue TM0n_TMC0n_Operation_FreeRunning
396 : /* Note : If use external trigger, use internal count clock only */
397 : #define TM01_PRM0nValue TM01_Clock| /* Use register bit macro
398 : TM0n_PRM0n_CountClock_TI00nEdge
399 : TM0n_PRM0n_TI00nEdge_Falling or
400 : TM0n_PRM0n_TI01nEdge_Rising or
401 : TM0n_PRM0n_TI01nEdge_Both
402 : Note : External trigger set only
403 : */ TM0n_PRM0n_T
: I00nEdge_Falling
404 : #define TM01_CRC0nValue TM0n_CRC0n_CR01nMode_Compare| TM0n_CRC0n_C
: R00nMode_Compare
405 : #define TM01_TOC0nValue TM0n_TOC0n_OneshotMode_Oneshot| TM0n_TOC0n_R
: everseTO0nByCR01n_Enable| /* Value selection
406 : TM0n_TOC0n_TO0nOut_NoChange
407 : TM0n_TOC0n_TO0nOut_Clear0
408 : TM0n_TOC0n_TO0nOut_Set1
409 : */ TM0n_TOC0n_T
: O0nOut_Clear0| TM0n_TOC0n_TO0nReverseByCR00n_Enable|
: TM0n_TOC0n_TO0nOut_Enable
410 :
411 : /* Interrupt settings */
412 : #define TM01_INTTM001 0
413 : #define TM01_INTTM011 0
414 :
415 :
416 : /*
417 : ***************************************
418 : ** TM50 configure
419 : **
420 : ** Please set operation mode here
421 : ***************************************
422 : */
423 : /* if no use set nouse = 1, if use some function set function = 1 */
424 : #define TM50_NotUse 1
425 : #define TM50_Interval 0
426 : #define TM50_ExternalEvent 0
427 : #define TM50_SquareOut 0
428 : #define TM50_PWMOut 0
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 9
*/
429 :
430 :
431 : /* Interrupt settings */
432 : #define TM50_INTTM50 0
433 :
434 :
435 : /*
436 : ***************************************
437 : ** TM51 configure
438 : **
439 : ** Please set operation mode here
440 : ***************************************
441 : */
442 : /* if no use set nouse = 1, if use some function set function = 1 */
443 : #define TM51_NotUse 1
444 : #define TM51_Interval 0
445 : #define TM51_ExternalEvent 0
446 : #define TM51_SquareOut 0
447 : #define TM51_PWMOut 0
448 :
449 :
450 : /* Interrupt settings */
451 : #define TM51_INTTM51 0
452 :
453 :
454 : /*
455 : ***************************************
456 : ** TMH0 configure
457 : **
458 : ** Please set operation mode here
459 : ***************************************
460 : */
461 : /* if no use set nouse = 1, if use some function set function = 1 */
462 : #define TMH0_NotUse 1
463 : #define TMH0_Interval 0
464 : #define TMH0_SquareOut 0
465 : #define TMH0_PWMOut 0
466 :
467 :
468 : /* Interrupt settings */
469 : #define TMH0_INTTMH0 0
470 :
471 :
472 : /*
473 : ***************************************
474 : ** TMH1 configure
475 : **
476 : ** Please set operation mode here
477 : ***************************************
478 : */
479 : /* if no use set nouse = 1, if use some function set function = 1 */
480 : #define TMH1_NotUse 1
481 : #define TMH1_Interval 0
482 : #define TMH1_SquareOut 0
483 : #define TMH1_PWMOut 0
484 : #define TMH1_CarrierOut 0
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 10
*/
485 :
486 :
487 : /* Interrupt settings */
488 : #define TMH1_INTTMH1 0
489 :
490 :
491 :
492 :
493 :
494 : #define _HDTIMER_
495 :
496 : /*
497 : *******************************************************************************
498 : ** Function proto type
499 : *******************************************************************************
500 : */
501 :
502 :
503 : void TM00_Init(void);
504 : void TM00_Enable(void);
505 : void TM00_Disable(void);
506 :
507 :
508 :
509 : void TM01_Init(void);
510 : void TM01_Enable(void);
511 : void TM01_Disable(void);
512 :
513 :
514 :
515 :
516 :
517 :
518 :
519 :
520 :
521 :
522 :
523 : /*
524 : *******************************************************************************
525 : ** MacroDefine
526 : *******************************************************************************
527 : */
528 :
529 : /* the value for IMS and IXS */
530 : #define MEMORY_IMS_SET 0xCC
531 : #define MEMORY_IXS_SET 0x00
532 :
533 : /*
534 : **-----------------------------------------------------------------------------
535 : **
536 : ** Abstract:
537 : ** main function
538 : **
539 : ** Parameters:
540 : ** None
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 11
*/
541 : **
542 : ** Returns:
543 : ** None
544 : **
545 : **-----------------------------------------------------------------------------
546 : */
547 : void main( void )
548 : {
549 : IMS = MEMORY_IMS_SET;
550 : IXS = MEMORY_IXS_SET;
551 : /* TODO. add user code */
552 : EI();
553 :
554 : TM00_Init();
555 : /* P01 as TO00 */
556 : P0.1 = 0;
557 : PM0.1 = 0;
558 : /* P00 as TI000 */
559 : PM0.0 = 1;
560 : TM00_Enable();
561 :
562 : TM01_Init();
563 : /* P06 as TO01 */
564 : P0.6 = 0;
565 : PM0.6 = 0;
566 : TM01_Enable();
567 :
568 : TOC00 |= TM0n_TOC0n_OneshotSoftTrigger;
569 : TOC01 |= TM0n_TOC0n_OneshotSoftTrigger;
570 :
571 : while(1){
572 : ;
573 : }
574 : }
/*
Target chip : uPD78F0547_80
Device file : V2.00
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -