tpu_qom_example6.c

来自「mpc564 时钟中断 时钟中断」· C语言 代码 · 共 110 行

C
110
字号
/**************************************************************************/
/* FILE NAME: tpu_qom_example6.c              COPYRIGHT (c) MOTOROLA 2002 */
/* VERSION: 1.1                                   All Rights Reserved     */
/*                                                                        */
/* DESCRIPTION: This sample program shows a simple example of a program   */
/* that uses the QOM API to control an output pin.                        */
/* 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  30/Sep/02    Initial version of function.           */
/* 1.1   J. Loeliger  13/Dec/02    Added while(1) to end code.            */
/**************************************************************************/

#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_qom.h"    /* TPU qom functions */

/* 14 constant events that can be put into ROM/FLASH*/
const union event_tag event[14] = {(0x0100 << 1) + TPU_QOM_FALLING_EDGE,\
                                   (0x0200 << 1) + TPU_QOM_RISING_EDGE,\
                                   (0x0300 << 1) + TPU_QOM_FALLING_EDGE,\
                                   (0x0200 << 1) + TPU_QOM_RISING_EDGE,\
                                   (0x0100 << 1) + TPU_QOM_FALLING_EDGE,\
                                   (0x0200 << 1) + TPU_QOM_RISING_EDGE,\
                                   (0x0200 << 1) + TPU_QOM_FALLING_EDGE,\
                                   (0x0200 << 1) + TPU_QOM_RISING_EDGE,\
                                   (0x0100 << 1) + TPU_QOM_FALLING_EDGE,\
                                   (0x0100 << 1) + TPU_QOM_RISING_EDGE,\
                                   (0x0100 << 1) + TPU_QOM_FALLING_EDGE,\
                                   (0x0100 << 1) + TPU_QOM_RISING_EDGE,\
                                   (0x0100 << 1) + TPU_QOM_FALLING_EDGE,\
                                   (0x0200 << 1) + TPU_QOM_RISING_EDGE}; 

void main ()
{
     struct TPU3_tag *tpua = &TPU_A;   /* pointer for TPU routines */
    
     setup_mpc500(40);       /*Setup device and program PLL to 40MHz*/	

/********************************************************************/
/* Define output: continuous complex output waveform                */
/* channel: 14                                                      */
/* mode: continuous                                                 */
/* timebase: TCR1                                                   */
/* initial pin state: high                                          */
/* first match: immediate                                           */
/* loop count: NA (not used in single shot match mode)              */
/* reference parameter: NA (not used in immediate first match mode) */
/* number of events: 14                                             */
/* event  1: $0100 counts then drive pin high.                      */
/* event  2: $0200 counts then drive pin high.                      */
/* event  3: $0300 counts then drive pin high.                      */
/* event  4: $0200 counts then drive pin low.                       */
/* event  5: $0100 counts then drive pin high.                      */
/* event  6: $0200 counts then drive pin high.                      */
/* event  7: $0200 counts then drive pin high.                      */
/* event  8: $0200 counts then drive pin low.                       */
/* event  9: $0100 counts then drive pin high.                      */
/* event 10: $0100 counts then drive pin high.                      */
/* event 11: $0100 counts then drive pin high.                      */
/* event 12: $0100 counts then drive pin low.                       */
/* event 13: $0100 counts then drive pin high.                      */
/* event 14: $0200 counts then drive pin high.                      */
/********************************************************************/
    
    tpu_qom_init(tpua, 14, TPU_PRIORITY_HIGH, TPU_QOM_CONTINUOUS, \
        TPU_QOM_TCR1, TPU_QOM_INIT_PIN_HIGH, TPU_QOM_IMMEDIATE,\
        0, 0, 14, (void *)event);

    while(1);

}

/*********************************************************************
 *
 * 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 + =
减小字号Ctrl + -
显示快捷键?