TMS320F2812实现SVPWM的完整程序
[复制链接]
//###########################################################################
//
// FILE: DSP281x_Ev.c
//
// TITLE: DSP281x Event Manager Initialization & Support Functions.
//
//###########################################################################
//
// Ver | dd mmm yyyy | Who | Description of changes
// =====|=============|======|===============================================
// 1.00| 11 Sep 2003 | L.H. | No change since previous version (v.58 Alpha)
//###########################################################################
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
//---------------------------------------------------------------------------
// InitEv:
//---------------------------------------------------------------------------
// This function initializes to a known state.
//
void InitEv(void)
{
EALLOW;
// Initalize EVA Timer1&Configure PWM1-PWM6
//EvaRegs.T1PR = 625; // period=625×2/25M ,PWM=20KHz
EvaRegs.T1PR = 781; // period=781×2/25M ,PWM=16KHz
EvaRegs.T1CNT = 0; // Timer1 counter
//定时器控制寄存器A
EvaRegs.GPTCONA.bit.TCMPOE=1; // enable timer compare
EvaRegs.GPTCONA.bit.T1PIN=0; // timer compare output
//计时器比较寄存器
EvaRegs.T1CMPR=0;
EvaRegs.EVAIMRA.bit.T1UFINT = 1;// enable Timer1 period interrupt
//EVA中断屏蔽寄存器
EvaRegs.EVAIFRA.bit.T1UFINT=1; // clear Timer1 period interrupt flag
//EVA中断标志寄存器
/****************************************************
TMODE = continuous up/down count
Input clock prescaler= X/1 (X=HSPCLK)=25MHz
Timer enable ; Timer compare enable
*****************************************************/
EvaRegs.T1CON.all = 0x0802; //连续增减计数,X/1 定时器尚未打开
//Enable compare for PWM1-PWM6
EvaRegs.CMPR1 = 781;
EvaRegs.CMPR2 = 781;
EvaRegs.CMPR3 = 781;
EvaRegs.ACTRA.all = 0x0999; // PWM1,2,3,4,5,6
EvaRegs.DBTCONA.all = 0x0AEC; // 死区2.88us 9/(25/8)
EvaRegs.COMCONA.all = 0xa600; //使能比较操作,不使能全局比较输出
//****************** QEP初始化 ********************
// EvbRegs.T4CON.all=0x1870;
// EvbRegs.T4CNT=0x0000;
// EvbRegs.T4PR=0xffff;
EvaRegs.T2CON.all=0x1870;
EvaRegs.T2CNT=0x0000;
EvaRegs.T2PR=0xffff;
EvaRegs.T1CON.bit.TENABLE=0;
//****************************************************
EDIS;
}
//===========================================================================
// No more.
//================
SVPWM_2812.rar
(741.71 KB, 下载次数: 29)
|