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

📄 tpu_fqm_ex1.c

📁 mpc564 时钟中断 时钟中断
💻 C
字号:
/**************************************************************************/
/* FILE NAME: tpu_tsm_ex1.c                   COPYRIGHT (c) MOTOROLA 2002 */
/* VERSION: 1.0                                   All Rights Reserved     */
/*                                                                        */
/* DESCRIPTION: This sample program shows a simple example of a program   */
/* that initializes the FQM function                                      */
/* The example uses the TPU A channel 0                                   */
/* The program is targeted for the MPC555 but should work on any MPC500   */
/* device with a TPU. For other devices the setup routines will also need */
/* to be changed.                                                         */
/*========================================================================*/
/* HISTORY           ORIGINAL AUTHOR: Jeff Loeliger                       */
/* REV      AUTHOR      DATE       DESCRIPTION OF CHANGE                  */
/* ---   -----------  ---------    ---------------------                  */
/* 1.0   J. Loeliger  03/Aug/02    Initial version of function.           */
/* 1.1   R, Dees      08/Sep/02    Convert to FQM example.                */
/**************************************************************************/

#include "mpc555.h"     /* Define all of the MPC555 registers, this needs to */
                        /* changed if other MPC500 devices are used.         */
#include "mpc500.c"     /* Configuration routines for MPC555 EVB, will need */
                        /* to be changed if other hardware is used.         */
#include "mpc500_util.h"    /* Utility routines for using MPC500 devices    */
#include "tpu_fqm.h"    /* TPU FQM functions */

/* Initialization parameters  */

     struct TPU3_tag *tpua = &TPU_A;   /* pointer for TPU routines */

void main ()
{
     int x;  /* Just an integer to hold a value  */
     UINT8 chan=0; /* set to  channel 0 */
     UINT16 freq;


/* Hardware Setup -- machine settings (watchdog, timers, speed, etc.) */
   setup_mpc500(40);       /*Setup device and programm PLL to 40MHz*/	
   setup_tpu(tpua); /* Do general TPU set up. */

   tpu_fqm_init(tpua, chan, TPU_PRIORITY_HIGH, TPU_FQM_FALL_EDGE_CONT, 
                 TPU_FQM_FALL, TPU_FQM_TCR1,0x8000);

   tpu_ready(tpua, chan);
   freq = tpu_fqm_get_pulse(tpua, chan);
   
   while(1){
      /* Hold at end of program */
      x=4;
      
     };
}    /* End of main */


void setup_tpu(struct TPU3_tag *tpu)
{
     tpu->TPUMCR.R = 0x2020; /* TCR1 prescaler divide by 2, supervisor and user acces. */
     tpu->TPUMCR3.R = 0x0040; /* enable enhanced prescaler - divide by 2 */
     tpu->TICR.B.CIRL = 5; /* set interupt level to 5.... */
     tpu->TICR.B.ILBS = 0;
}

/*********************************************************************
 *
 * Copyright:
 *	MOTOROLA, INC. All Rights Reserved.  
 *  You are hereby granted a copyright license to use, modify, and
 *  distribute the SOFTWARE so long as this entire notice is
 *  retained without alteration in any modified and/or redistributed
 *  versions, and that such modified versions are clearly identified
 *  as such. No licenses are granted by implication, estoppel or
 *  otherwise under any patents or trademarks of Motorola, Inc. This 
 *  software is provided on an "AS IS" basis and without warranty.
 *
 *  To the maximum extent permitted by applicable law, MOTOROLA 
 *  DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING 
 *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
 *  PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE 
 *  SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY 
 *  ACCOMPANYING WRITTEN MATERIALS.
 * 
 *  To the maximum extent permitted by applicable law, IN NO EVENT
 *  SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING 
 *  WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS 
 *  INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
 *  LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.   
 * 
 *  Motorola assumes no responsibility for the maintenance and support
 *  of this software
 ********************************************************************/

⌨️ 快捷键说明

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