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.

[参考译文] CCS/TMS320F28335:我已经设置了 ECAP Cputimer0、1、ADC、Xintf13、14个中断、Cputimer 在分步运行中正常工作、但在全速运行时停止。

Guru**** 2614265 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/696346/ccs-tms320f28335-i-have-set-up-ecap-cputimer0-1-adc-xintf13-14-interrupts-and-cputimer-works-normally-in-step-run-but-stops-when-in-full-speed

器件型号:TMS320F28335

工具/软件:Code Composer Studio

当我监控 Cputimer 寄存器时、令人惊讶的 TIMH 和 TIM 仍在运行、TSS = 0;但 Cputimer interruptcount 保持为1或0

首先,我已将 ConfigCputimer()修改为:

空 ConfigCpuTimer (struct CPUTIME_VARS *定时器、uint32频率、uint32周期、uint32预分频)

uint32温度;
uint16 SETPSC;
uint16 SETPSCH;

//初始化计时器周期:

SETPSCH =(UINT16)预分频>> 8;
//预分频设置为1、2、3、4、5、6、7…… 但最好不要太多、只能进行补偿
//时钟跳闸就足够了。
if (((uint16)预分频>> 8 > 0)

SETPSC=(预分频-((UINT16)预分频0xFF00);

否则 SETPSC =预分频;
Timer->CPUFreqInMHz =频率;
Timer->PeriodInUSec =周期;
temp =(long)(period*Freq/Prescale);
Timer->RegsAddr->PRD.All = temp;


Timer->RegsAddr->TPR.All = 0;
Timer->RegsAddr->TPRH。ALL = 0;

//初始化计时器控制寄存器:
timer->RegsAddr->TCR.bit.TSS = 1;// 1 =停止计时器,0 =启动/重新启动计时器
timer->RegsAddr->TCR.bit.TRB = 1;// 1 =重新加载计时器
Timer->RegsAddr->TCR.bit.Soft = 1;
Timer->RegsAddr->TCR.bit.FREE = 0;//计时器自由运行
Timer->RegsAddr->TCR.bit.tie = 1;// 0 =禁用/ 1 =启用计时器中断
Timer->RegsAddr->TPRH.bit.TDDRH =SETPSCH;
Timer->RegsAddr->TPR.bit.TDDR = SETPSC;
Timer->RegsAddr->TPR.bit.PSC = 0x00;
Timer->RegsAddr->TPRH.bit.PSCH = 0x00;
// Timer->RegsAddr->PRD.All = 0x08F0D180;
Timer->RegsAddr->TIM.All = 0x00000000;
//复位中断计数器:
Timer->InterruptCount = 0;
Timer->RegsAddr->TCR.bit.TSS = 0;

我已经按如下方式设置了其他中断 ISR:


_interrupt void xint3_ISR (void)

DELAY_US (10);
if (GpioDataRegs.GPBDAT.bit.GPIO60 ==0)

if (start_con = stop)

START_CON =启动;

其他

if (start_con = start)
START_CON =停止;


/*这用于两个按钮
IF (CHZ<=400)

CHZ+=1;

EPwm1Regs.TBPRD = RPM2EPR (1.0f/CHZ、CPHLM、CSU、CD);


其他

EPwm1Regs.TBPRD = RPM2EPR (1.0f/400、CPHLM、CSU、CD);

*
Xint3Count++;

//确认此中断以从组1获取更多内容
PieCtrlRegs.PIEACX.ALL = PIEACK_Group12;

_interrupt void CPU_Timer1_ISR (void)

CpuTimer1Regs.TCR.bit.TIF = 1;
CpuTimer1.InterruptCount++;

//确认此中断以从组1接收更多中断
EDIS;


_interrupt void CPU_timer0_ISR (void)

CpuTimer0Regs.TCR.bit.TIF = 1;
// GpioDataRegs.GPADD.bit.GPIO0 =~(GpioDataRegs.GPADD.bit.GPIO0);
if (start_con = start)

IF (CHZ<400.0f)


CHZ+=1.0f;

EPwm1Regs.TBPRD = RPM2EPR (1.0f/CHZ、CPHLM、CSU、CD);


其他

EPwm1Regs.TBPRD = RPM2EPR (1.0f/4000.0f、CPHLM、CSU、CD);
CHZ = 400.0f;


其他

if (start_con = stop)

if (CHZ>1.0f)

CHZ-=1.0f;

EPwm1Regs.TBPRD = RPM2EPR (1.0f/CHZ、CPHLM、CSU、CD);


其他

EPwm1Regs.TBPRD = RPM2EPR (0.0f、CPHLM、CSU、CD);


CpuTimer0.InterruptCount++;

//确认此中断以从组1接收更多中断
PieCtrlRegs.PIEACX.ALL = PIEACK_Group1;

_interrupt void eCAP1_ISR (void)

易失性 uint16 q;
易失性浮点 RPM = 0.0f;
易失性浮点 DELTAT = 0.0f;
if (q>=512) q = 0;
// volatile uint16 array_index;

TIMESTAMP[q++]= CpuTimer1.InterruptCount;
while (timestamp[1]!=0)

DELTAT = 0.1*(TIMESTAMP[q]-TIMESTAMP[q-1]);
R_CRPM =(1.6f/360.0f)/DELTAT;


//等待 INT1
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;
GpioDataRegs.GPBSET.BIO34 = 1;
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;

#if inline_shift
/*使用 CpuTimer0作为计数器
TIMESTAMP[array_index]= CpuTimer0.InterruptCount;
//每个过去的 Count 循环都是0.1秒的时间。
r_RPM[array_index]=(timestim[array_index]- timestim[array_index-1])*60*NUM_Hull;
R_CRPM = R_RPM/[array_index];
*
SampleTable[array_index+]=(AdcRegs.ADCRESULT0)>>4);

#endif

GpioDataRegs.GPBCLEAR.bit.GPIO34 = 0;//清除 GPIO34以进行监控-可选

ECap1Regs.ECCLR.bit.CEVT4 = 1;
ECap1Regs.ECCLR.bit.INT = 1;
ECap1Regs.ECCTL2.bit.rearm = 0;


if (array_index >= 127)

array_index = 0;

//确认此中断以接收来自组4的更多中断
PieCtrlRegs.PIEACX.ALL = PIEACK_group4;

什么可能出错? 我一直在思考这个问题数周。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Owen、

    您如何验证计时器仍在运行?

    您能否在启用和禁用计时器的情况下读回配置并比较这两者?

    Cody