#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "init_sin.h"
#include "math.h"
#include "test1.h"
extern float e_A, e_B, e_C;//实际电压值
extern float i_A, i_B, i_C;//实际电流值
//extern float VAref,VBref,VCref;
//extern float Viref,ViBref,ViCref;
void ABC_ref(void) //初始化正弦波数据
{
int i;
for(i=0;i<=359;i++)
{
// e_A = 311*sin(2*PI*i/360)*0.0195789;
// e_B = 311*sin(2*PI*(i-120)/360)*0.019804;
// e_C = 311*sin(2*PI*(i+120)/360)*0.0196121;
//
// i_A = 6.8*sin(2*PI*i/360)*0.0039398;
// i_B = 6.8*sin(2*PI*(i-120)/360)*0.0035504;
// i_C = 6.8*sin(2*PI*(i+120)/360)*0.0037290;
e_A = 311*sin(2*M_PI*i/360);
e_B = 311*sin(2*M_PI*(i-120)/360);
e_C = 311*sin(2*M_PI*(i+120)/360);
i_A = 6.8*sin(2*M_PI*i/360);
i_B = 6.8*sin(2*M_PI*(i-120)/360);
i_C = 6.8*sin(2*M_PI*(i+120)/360);
}
}
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "test1.h"
#include "math.h"
#include "init_sin.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;
//extern float u_alpha0;
//extern float u_beta0;
//extern float center_sector_alpha[6];
//extern float center_sector_beta[6];
//extern unsigned char N;
//Uint16 j=0;
//
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" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "math.h"
#include "test1.h"
#include "init_sin.h"
float e_A, e_B, e_C;//实际电压值
float i_A, i_B, i_C;//实际电流值
//float Js;
//float J_opt;
float e_alpha;
float e_beta;
float i_alpha;
float i_beta;
float Ttype_ps;
float Ttype_qs;
float Ep;
float Eq;
float fp;
float fq;
//float u_alpha0;
//float u_beta0;
//float center_sector_alpha[6];
//float center_sector_beta[6];
//unsigned char N=0;
#define JDQ_XH GpioDataRegs.GPACLEAR.bit.GPIO31 = 1 //继电器吸合
#define JDQ_DK GpioDataRegs.GPASET.bit.GPIO31 = 1 //继电器断开
void configtestled(void);
void configJDQ(void);
interrupt void cpu_timer0_isr(void);
int main(void)
{
InitSysCtrl();
configtestled();
configJDQ();
InitXintf(); // 配置外部存储器的访问时序
DINT; //禁用CPU中断
InitPieCtrl(); // 初始化中断控制寄存器,禁用所有PIE中断并清楚标志位
IER = 0x0000; // 关闭总中断
IFR = 0x0000; // 清除中断信号
InitPieVectTable(); // 初始化中断向量表
EALLOW;
PieVectTable.TINT0 = &cpu_timer0_isr;
// PieVectTable.SCIRXINTB = &sci485_isr;
EDIS;
// EALLOW;
// SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=0; //同步PWM时钟信号
// EDIS;
//
//
//
// EALLOW;
// SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1; //同步PWM时钟信号
// EDIS;
InitCpuTimers();
// ConfigCpuTimer(&CpuTimer0, 150, 33.3); //周期10us,开关频率18kHz
ConfigCpuTimer(&CpuTimer0, 150, 100); //周期10us,开关频率10kHz
StartCpuTimer0();
// Init_sci_485_config();
IER |= M_INT1;//使能CPU INT1和INT9
IER |= M_INT9;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //使能pie模块
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; //Enable TINT0(1.7)
PieCtrlRegs.PIEIER9.bit.INTx3 = 1; //Enable SCIRXINTB(9.3)
//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
EINT;
ERTM;
CpuTimer0Regs.TCR.bit.TSS = 0; //立即启动定时器0
JDQ_XH;
// balance_flag = 0;
for(;;)
{
if(CpuTimer0Regs.TCR.bit.TIF == 0)//if(current_flag == 1) // 确保中断已更新全部数据
{
;
}
else
{;}
}
}
interrupt void cpu_timer0_isr(void)
{
// semaphore = 1; // 中断服务函数中设置信号量
ABC_ref();
formula(); //在循环中调用formula()函数
// sector_partition();
CpuTimer0.InterruptCount = (CpuTimer0.InterruptCount >= 18000)? 0:CpuTimer0.InterruptCount+1; //1s
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP1;
CpuTimer0Regs.TCR.bit.TIF = 1; //写1清除中断标志(该位为1表明进入中断,该位为0表明中断函数结束)
CpuTimer0Regs.TCR.bit.TRB = 1;
}
CCS代码问题请教。以上两段代码是我写的两段功能函数,但是运行时第二段代码中的变量不随着第一段代码中的变量变化,如下图所示。中断没有问题。请问这是什么原因呢?