📄 tpu_mcpwm_example2.c
字号:
/*********************************************************************
*
* 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
********************************************************************/
/****************************************************************************/
/* FILE NAME: tpu_mcpwm_example2.c COPYRIGHT (c) MOTOROLA 2002 */
/* VERSION: 1.0 All Rights Reserved */
/* */
/* DESCRIPTION: This sample program shows a MCPWM example in center-aligned */
/* mode that generates two PWM pulses with a period of 256 TCR1 clocks, */
/* sharing a common HIGH_TIME and suitable for driving an inverter. The */
/* required DEAD_TIME = 4 and the master channel is on channel 0 while */
/* channels 1, 2, 3 and 4 are slaves. Periodic interrupts every 10 PWM */
/* periods. Initialize with a duty cycle of 50%. */
/* */
/* 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: Mario Ramiro Perez II */
/* */
/* REV AUTHOR DATE DESCRIPTION OF CHANGE */
/* --- ----------- --------- --------------------- */
/* 1.0 Mario R. Perez 25 Sep 02 Initial version of function. */
/****************************************************************************/
#include "mpc555.h" /* Define MPC555 registers, this needs to be */
/* changed if other MPC500 devices are used. */
#include "mpc500_util.h" /* Utility routines for using MPC500 devices */
#include "tpu_mcpwm.h" /* TPU MCPWM functions */
void main ()
{
struct TPU3_tag *tpua = &TPU_A; /* pointer for TPU routines */
setup_555();
/* Initialize MCPWM Master Init function with: */
/* - TPU A Channel 0 set */
/* - Priority set to High */
/* - Period set to 0x100 */
/* - IRQ Rate set to 0xA */
tpu_mcpwm_master_init(tpua, 0, TPU_PRIORITY_HIGH, 0x100, 0xA);
/* Initialize SlaveA Center Mode (Inverted): */
/* - TPU A Channel 1 set */
/* - Priority set to High */
/* - Period set to 0x100 */
/* - Dead Time set to 0x0 */
/* - High Time Pointer set to 0x21 */
/* - Polarity is set to Inverted */
/* - Master channel is running on TPU ch 0 */
tpu_mcpwm_slavea_centermode_init(tpua, 1, TPU_PRIORITY_HIGH, 0x100, 0x0, 0x21, INVERTED, 0);
/* Initialize SlaveB Center Mode function with: */
/* - TPU A Channel 2 set */
/* - Priority set to High */
/* - High Time set to 0x80 */
/* - Polarity is set to Inverted */
/* - Slave A channel is running on TPU ch 1 */
tpu_mcpwm_slaveb_centermode_init(tpua, 2, TPU_PRIORITY_HIGH, 0x80, INVERTED, 1);
/* Initialize SlaveA Center Mode (Non-Inverted):*/
/* - TPU A Channel 3 set */
/* - Priority set to High */
/* - Period set to 0x100 */
/* - Dead Time set to 0x4 */
/* - High Time Pointer set to 0x23 */
/* - Polarity is set to Non-Inverted */
/* - Master channel is running on TPU ch 0 */
tpu_mcpwm_slavea_centermode_init(tpua, 3, TPU_PRIORITY_HIGH, 0x100, 0x4, 0x23, NONINVERTED, 0);
/* Initialize SlaveB Center Mode function with: */
/* - TPU A Channel 4 set */
/* - Priority set to High */
/* - High Time set to 0 (don't care) */
/* - Polarity is set to Non-Inverted */
/* - Slave A channel is running on TPU ch 3 */
tpu_mcpwm_slaveb_centermode_init(tpua, 4, TPU_PRIORITY_HIGH, 0, NONINVERTED, 3);
tpu_interrupt_enable(tpua, 0); /* enable MCPWM interrupts */
while (1) { /* loop and measure */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -