首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

我编写的SPWM程序,请高手指导!

我编写的SPWM程序,请高手指导!

#include "DSP28_Device.h"
#include "math.h" //计算正弦表要加入该句

//中断子程序声明
interrupt void T1pint_isr(void);
//interrupt void T4pint_isr(void);
//interrupt void adc_isr(void);
//interrupt void Scirxinta_isr(void);
//interrupt void pdpaint_isr(void);

//void stop_pwm(void);
//void start_pwm(void);

#define PI2 3.1416*2
#define FC 14400
#define FC7 400
#define FC2 1000
#define sinlen 36

long FR_2;
long FG1;
long T1pr;
long T2pr,T3pr;
long N_1000;
long de_128;
int j,k;
int sindata[36];

void main(void)
{


/*初始化系统*/
InitSysCtrl();

//初始化通用IO口
/*关中断*/
DINT;
IER = 0x0000;
IFR = 0x0000;
EALLOW;
GpioMuxRegs.GPAMUX.all =0x003F; //EVA pwm1-6
GpioMuxRegs.GPAMUX.bit.CAP3QI1_GPIOA10=0; //GPIOA10
GpioMuxRegs.GPADIR.bit.GPIOA10=0;
GpioMuxRegs.GPBMUX.bit.PWM7_GPIOB0=1;
GpioMuxRegs.GPBMUX.bit.PWM11_GPIOB4=1;
GpioMuxRegs.GPBMUX.bit.PWM9_GPIOB2=0;
GpioMuxRegs.GPBDIR.bit.GPIOB2=1;
GpioMuxRegs.GPFMUX.bit.SCITXDA_GPIOF4=1;
GpioMuxRegs.GPFMUX.bit.SCIRXDA_GPIOF5=1;
EDIS;

/*初始化PIE控制寄存器*/
InitPieCtrl();

/*初始化PIE矢量表*/
InitPieVectTable();

//初始化ADC寄存器
InitAdc();
AdcRegs.MAX_CONV.all=0x0005;
AdcRegs.CHSELSEQ1.all=0xC9BD;
AdcRegs.CHSELSEQ2.all=0x008A;
AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1=1;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1=1;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=5;

/*初始化EV*/
//InitEv();

/*初始化外设*/
// InitPeripherals();

//初始化Xintf
InitXintf();

//中断使能
EALLOW;
PieVectTable.T1PINT=&T1pint_isr;
//PieVectTable.T4PINT=&T4pint_isr;
//PieVectTable.ADCINT=&adc_isr;
//PieVectTable.RXAINT=&Scirxinta_isr;
//PieVectTable.PDPINTA=&pdpaint_isr;
EDIS;
PieCtrl.PIEIER2.bit.INTx4=1;
PieCtrl.PIEIER5.bit.INTx1=1;
PieCtrl.PIEIER1.bit.INTx6=1;
PieCtrl.PIEIER9.bit.INTx1=1;
PieCtrl.PIEIER1.bit.INTx1=1;
IER |=(M_INT1|M_INT2|M_INT5|M_INT9);

EINT;
ERTM;

//在线计算注正弦表
for(j=0;j<36;j++)
{

sindata[j]=1302-1302*0.9*sin((j+0.75)*PI2/36);

}

while(1)
{
;
}

}

返回列表