Other Parts Discussed in Thread: TMS320F28377D
Hi,
We are using TMS320F28377D, delfino DSP controller in our project. We are controlling around 12 stepper motor using ePMWs. They are configured to generate interrupt for every pulse. In ePWM ISR, we are changing the TBPRD and CMPA/CMPB registers to implement ramp up and ramp down for smooth motor start and stop. After the desired pulses are over, we are stopping the ePWM.
Now, the problem we are facing is, after certain sequence of motor start and stop, we found out that one or two ePWM TBPRD & CMPA/CMPB registers are resetting to 0xFFFF and 0x00 respectively even though we are loading a proper period and duty cycle.
Below code is used for configuring the ePWM,
(*ePWM[Channel]).TBCTL.bit.PRDLD = TB_SHADOW;
(*ePWM[Channel]).TBPRD = period-1;
(*ePWM[Channel]).CMPA.bit.CMPA = 0;
(*ePWM[Channel]).TBPHS.all = 0;
(*ePWM[Channel]).TBCTR = 0;
(*ePWM[Channel]).TBCTL.bit.CTRMODE = TB_COUNT_UP;
(*ePWM[Channel]).TBCTL.bit.PHSEN = TB_DISABLE;
(*ePWM[Channel]).TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
(*ePWM[Channel]).TBCTL.bit.HSPCLKDIV = 7; //PWM_TB_DIV10;
(*ePWM[Channel]).TBCTL.bit.CLKDIV = 7; // PWM_TB_DIV8;
(*ePWM[Channel]).TBCTL.bit.FREE_SOFT = 3;
(*ePWM[Channel]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
(*ePWM[Channel]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
(*ePWM[Channel]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
(*ePWM[Channel]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
(*ePWM[Channel]).AQCTLA.bit.ZRO = AQ_CLEAR;
(*ePWM[Channel]).AQCTLA.bit.CAU = AQ_CLEAR;
// Interrupt where we will change the Compare Values
(*ePWM[Channel]).ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
(*ePWM[Channel]).ETSEL.bit.INTEN = 1; // Enable INT
(*ePWM[Channel]).ETPS.bit.INTPRD = ET_1ST; //ET_3RD; 0->fist event, 1-> second event, 2-> third event // Generate INT on 3rd event
Following code is used for starting and stopping of ePWM,
if(State == START)
{
(*ePWM[Channel]).TBPRD = period-1;
(*ePWM[Channel]).CMPA.bit.CMPA = (Uint16)(period*0.5); // set duty 50%
(*ePWM[Channel]).AQCTLA.bit.ZRO = AQ_SET; // PWM toggle high/low
(*ePWM[Channel]).AQCTLA.bit.CAU = AQ_CLEAR;
(*ePWM[Channel]).ETSEL.bit.INTEN = 1; // Enable INT
}
else
{
(*ePWM[Channel]).ETSEL.bit.INTEN = 0; // Disable INT
(*ePWM[Channel]).CMPA.bit.CMPA = 0; //DUTY_PERCENT_0; // set duty 0%
(*ePWM[Channel]).AQCTLA.bit.ZRO = AQ_CLEAR; // PWM toggle high/low
(*ePWM[Channel]).AQCTLA.bit.CAU = AQ_CLEAR;
}
We have cross verified our code and nowhere we are loading 0xFFFF to TBPRD. What could be the cause for the registers value resetting.