我想给DSP28335一个假的三相并网电压电流数据来测试代码,代码如下所示,但是我的ea、eb、ec、ia、ib、ic正常在变换,接下来的计算代码却不能输出结果,这是为什么?
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
#include "init_sin.h"
#include "test1.h"
#include "math.h"
extern float e_A, e_B, e_C;
extern float i_A, i_B, i_C;
void ABC_ref(void)
{
int i;
for(i=0;i<=359;i++)
{
e_A = 311*sin(2*PI*i/360);
e_B = 311*sin(2*PI*(i-120)/360);
e_C = 311*sin(2*PI*(i+120)/360);
i_A = 6.8*sin(2*PI*i/360);
i_B = 6.8*sin(2*PI*(i-120)/360);
i_C = 6.8*sin(2*PI*(i+120)/360);
}
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
#include "init_sin.h"
#include "test1.h"
#include "math.h"
extern float i_A,i_B,i_C;
extern float e_A, e_B, e_C;
extern float e_alpha;
extern float e_beta;
extern float i_alpha;
extern float i_beta;
extern float Ttype_ps;
extern float Ttype_qs;
extern float Ep;
extern float Eq;
void formula(void)
{
e_alpha = e_A-0.5*e_B-0.5*e_C;
e_beta = 1.7320508076/2.0*e_B-1.7320508076/2.0*e_C;
e_alpha = 0.6666666667*e_alpha;
e_beta = 0.6666666667*e_beta;
i_alpha = i_A-0.5*i_B-0.5*i_C;
i_beta = 1.7320508076/2.0*i_B-1.7320508076/2.0*i_C;
i_alpha = 0.6666666667*i_alpha;
i_beta = 0.6666666667*i_beta;
Ttype_ps = e_alpha*i_alpha+e_beta*i_beta;
Ttype_qs = e_beta*i_alpha-e_alpha*i_beta;
Ttype_ps = 1.5*Ttype_ps;
Ttype_qs = 1.5*Ttype_qs;
Ep = Pref-Ttype_ps;
Eq = Qref-Ttype_qs;
}
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
#include "math.h"
#include "test1.h"
#include "init_sin.h"
float e_A_arr[360], e_B_arr[360], e_C_arr[360];
float i_A_arr[360], i_B_arr[360], i_C_arr[360];
float e_A, e_B, e_C;
float i_A, i_B, i_C;
float e_alpha;
float e_beta;
float i_alpha;
float i_beta;
float Ttype_ps;
float Ttype_qs;
float Ep;
float Eq;
#define JDQ_XH GpioDataRegs.GPACLEAR.bit.GPIO31 = 1
#define JDQ_DK GpioDataRegs.GPASET.bit.GPIO31 = 1
void configJDQ(void);
interrupt void cpu_timer0_isr(void);
void main(void)
{
InitSysCtrl();
configJDQ();
InitXintf();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.TINT0 = &cpu_timer0_isr;
EDIS;
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 150, 100);
StartCpuTimer0();
IER |= M_INT1;
IER |= M_INT9;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIEIER9.bit.INTx3 = 1;
EINT;
ERTM;
CpuTimer0Regs.TCR.bit.TSS = 0;
JDQ_XH;
for(;;)
{
if(CpuTimer0Regs.TCR.bit.TIF == 0)
{
;
}
else
{;}
}
}
interrupt void cpu_timer0_isr(void)
{
ABC_ref();
formula();
CpuTimer0.InterruptCount = (CpuTimer0.InterruptCount >= 18000)? 0:CpuTimer0.InterruptCount+1;
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP1;
CpuTimer0Regs.TCR.bit.TIF = 1;
CpuTimer0Regs.TCR.bit.TRB = 1;
}