|
本人新手上路,学用2812的开发板写一个spwm输出的程序。可是改变CMPR1之后输出波形无反应,PWM1管脚还是等宽的脉冲,请问这是什么原因呢?多谢指点!
程序如下:
#include \"DSP281x_Device.h\" // DSP281x Headerfile Include File
#include \"DSP281x_Examples.h\" // DSP281x Examples Include File
#include \"math.h\"
#include \"stdio.h\"
#define Pr_T1 3000 // the period of T1
unsigned char Width[]={0x0D66,0x1AC2,0x280C,0x3539,0x4242,0x4f1b,0x5bbe,0x681f,0x7438,0x8000,0x8b6d,0x9679,0xa11b,0xab4b,0xb504,0xbe3e,0xc6f2,0xcf1b,0xd6b2,0xddb3,0xe418,0xe9dd,0xeefe,0xf377,0xf746,0xfa67,0xfcd8,0xfe98,0xffa5,0xffff};
unsigned char i=0; // which section the vector located.
void initEva(void)
{
EvaRegs.T1PR=Pr_T1; //Timer1 period
EvaRegs.T1CON.all=0x0842;//内部时钟周期,使能定时器及其比较功?
EvaRegs.GPTCONA.all=0x0052;//disable Timer2
EvaRegs.ACTRA.all=0x0666; //
EvaRegs.COMCONA.all=0x82E0; //disable SVPWM
EvaRegs.CMPR1=0x0D66; //initialize CMPRx
}
void main(void)
{
InitSysCtrl();
EALLOW;
GpioMuxRegs.GPAMUX.all = 0x00FF; // EVA PWM 1-6 pins
GpioMuxRegs.GPBMUX.all = 0x00FF; // EVB PWM 7-12 pins
EDIS;
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
initEva();
while(i<30)
{
EvaRegs.COMCONA.all=0x82E0; //disable SVPWM
EvaRegs.CMPR1=Width;
i++;
}
for(;;
}
[ 本贴由 searchfox 于 2008-5-15 08:36 PM 最后编辑 ]
|
|