This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于如何测量28335一个工作循环时间的问题



各位TI友,德仪员工你们好,

  我由于控制的特殊性,必须使用空循环反复对ADC采样寄存器的值读取,运算,赋值,控制GPIO。变换器频率设计为50K,因此循环的处理速度得非常高,所以特向大家请教我这么一个空循环函数如何测量他的一个运算周期。

  程序之所以采用空循环反复运算的原因,是有一个控制环里需要实现模拟电路中的比较器功能(这个是一个采样信号和参考值的实时比较)。我才用if语句不断判断才可以实现,不清楚28335是否有其他市县该功能的方法。

while(1)
{

Voltage1[ConversionCount] = AdcRegs.ADCRESULT0 >>4;
Current1[ConversionCount] = AdcRegs.ADCRESULT1 >>4;

Voltage=3.0*Voltage1[ConversionCount]/4096; // 还原电压的真实测量值
Current=3.0*Current1[ConversionCount]/4096; // 还原电流的真实测量值

//数字PI控制算法

VoltageError=RefVoltage-Voltage;
ma+=Kp*(VoltageError-last_VoltageError)+Ki*VoltageError;
if(ma>=1) ma=1;
else if(ma<=0) ma=0;
last_VoltageError=VoltageError;
CMPVoltage=ma*SP; // 得到调制信号,并对CMPA赋值

EPwm1Regs.CMPA.half.CMPA = CMPVoltage; // Set compare A value


// 电流环控制信号的产生
if (Current<=RefCurrent)
GpioDataRegs.GPADAT.bit.GPIO1=1;
else if(Current>RefCurrent)
GpioDataRegs.GPADAT.bit.GPIO1=0;

// If 40 conversions have been logged, start over
if(ConversionCount == 9)
{
ConversionCount = 0;
}
else ConversionCount++;


// Reinitialize for next ADC sequence
// AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
// AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
// PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE

}