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.

请教一下,每次的pwm波形输出有延时。蓝色的为切换相,黄色的为pwm波,不知道问题出在哪里?

#define BLDCPWM_UCMP_MACRO(ch1,ch2,ch3,v) /* */\
/* Convert "Period" (Q15) modulation function to Q0 */\
Tmp = (int32)v.PeriodMax*(int32)v.MfuncPeriod; /* Q15 = Q0xQ15 */\
Period = (int16)(Tmp>>15); /* Q15 -> Q0 (Period) */\
/* */\
/* Check PwmActive setting */\
if (v.PwmActive==1) /* PWM active high */\
GPR0_BLDC_PWM = 0x7FFF - v.DutyFunc; /* */\
/* */\
else if (v.PwmActive==0) /* PWM active low */\
GPR0_BLDC_PWM = v.DutyFunc; /* */\
/* */\
/* Convert "DutyFunc" or "GPR0_BLDC_PWM" (Q15) duty modulation function to Q0 */\
Tmp = (int32)Period*(int32)GPR0_BLDC_PWM; /* Q15 = Q0xQ15 */\

if (v.CmtnPointer==0) /* */ \
{ /* */\

/* (*ePWM[ch1]).AQCSFRC.bit.CSFA = 2; */\
(*ePWM[ch1]).AQCSFRC.bit.CSFA = 0; /* Forcing disabledd on output A of EPWM1 */\
(*ePWM[ch1]).AQCTLA.bit.CAU = 1; /* Set high when CTR = CMPA on UP-count */\
(*ePWM[ch1]).AQCTLA.bit.CAD = 2; /* Set low when CTR = Zero */\
(*ePWM[ch1]).CMPA.half.CMPA = (int16)(Tmp1);/* PWM signal on output A of EPWM1 (Q15 -> Q0) */\
(*ePWM[ch1]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM1 */\
\
(*ePWM[ch2]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM2 */\
(*ePWM[ch2]).AQCSFRC.bit.CSFB = 1; /* Forcing a continuous Low on output A of EPWM2 */\
\
(*ePWM[ch3]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM3 */\
(*ePWM[ch3]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous LHighow on output B of EPWM3 */\
} /* */\
/* */\
/* State s2: current flows to motor windings from phase A->C, de-energized phase = B */\
else if (v.CmtnPointer==1) /* */\
{ /* */\

/* (*ePWM[ch1]).AQCSFRC.bit.CSFA = 2; */\
(*ePWM[ch1]).AQCSFRC.bit.CSFA = 0; /* Forcing disabledd on output A of EPWM1 */\
(*ePWM[ch1]).AQCTLA.bit.CAU = 1; /* Set high when CTR = CMPA on UP-count */\
(*ePWM[ch1]).AQCTLA.bit.CAD = 2; /* Set low when CTR = Zero */\
(*ePWM[ch1]).CMPA.half.CMPA = (int16)(Tmp1); /* PWM signal on output A of EPWM1 (Q15 -> Q0) */\
(*ePWM[ch1]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous Low on output B of EPWM1 */\
/* */\
(*ePWM[ch2]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM2 */\
(*ePWM[ch2]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM2 */\
/* */\
(*ePWM[ch3]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM3 */\
(*ePWM[ch3]).AQCSFRC.bit.CSFB = 1; /* Forcing a continuous Low on output B of EPWM3 */\
} /* */\
/* */\
/* State s3: current flows to motor windings from phase B->C, de-energized phase = A */\
else if (v.CmtnPointer==2) /* */\
{ /* */\

/* (*ePWM[ch2]).AQCSFRC.bit.CSFA = 2;*/\
(*ePWM[ch2]).DBCTL.all = BLDCPWM_DBCTL_INIT_STATE; /* */ \
(*ePWM[ch2]).AQCSFRC.bit.CSFA = 0; /* Forcing disabled on output A of EPWM2 */\
(*ePWM[ch2]).AQCTLA.bit.CAU = 1; /* Set high when CTR = CMPA on UP-count */\
(*ePWM[ch2]).AQCTLA.bit.CAD = 2; /* Set low when CTR = Zero */\
(*ePWM[ch2]).CMPA.half.CMPA = (int16)(Tmp1); /* PWM signal on output A of EPWM2 (Q15 -> Q0) */\
(*ePWM[ch2]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM2 */\
/* */\
(*ePWM[ch3]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM3 */\
(*ePWM[ch3]).AQCSFRC.bit.CSFB = 1; /* Forcing a continuous Low on output B of EPWM3 */\
} /* */\
/* */\
/* State s4: current flows to motor windings from phase B->A, de-energized phase = C */\
else if (v.CmtnPointer==3) /* */\
{ /* */\

/* (*ePWM[ch2]).AQCSFRC.bit.CSFA = 2; */ \

(*ePWM[ch2]).AQCSFRC.bit.CSFA = 0; /* Forcing disabled on output A of EPWM2 */ \
(*ePWM[ch2]).AQCTLA.bit.CAU = 1; /* Set high when CTR = CMPA on UP-count */ \
(*ePWM[ch2]).AQCTLA.bit.CAD = 2; /* Set low when CTR = Zero */ \
(*ePWM[ch2]).CMPA.half.CMPA = (int16)(Tmp1); /* PWM signal on output A of EPWM2 (Q15 -> Q0) */ \
(*ePWM[ch2]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM2 */ \
/* */ \
(*ePWM[ch3]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM3 */ \
(*ePWM[ch3]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM3 */ \
} /* */ \
/* */ \
/* State s5: current flows to motor windings from phase C->A, de-energized phase = B */ \
else if (v.CmtnPointer==4) /* */ \
{ /* */ \
(*ePWM[ch1]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM1 */ \
(*ePWM[ch1]).AQCSFRC.bit.CSFB = 1; /* Forcing a continuous Low on output B of EPWM1 */ \
/* */ \
(*ePWM[ch2]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM2 */ \
(*ePWM[ch2]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM2 */ \
/* */ \

/* (*ePWM[ch3]).AQCSFRC.bit.CSFA = 2;*/\
(*ePWM[ch3]).AQCSFRC.bit.CSFA = 0; /* Forcing disabled on output A of EPWM3 */ \
(*ePWM[ch3]).AQCTLA.bit.CAU = 1; /* Set high when CTR = CMPA on UP-count */ \
(*ePWM[ch3]).AQCTLA.bit.CAD = 2; /* Set low when CTR = Zero */ \
(*ePWM[ch3]).CMPA.half.CMPA = (int16)(Tmp1); /* PWM signal on output A of EPWM3 (Q15 -> Q0) */ \
(*ePWM[ch3]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM3 */ \
} /* */ \
/* */ \
/* State s6: current flows to motor windings from phase C->B, de-energized phase = A */ \
else if (v.CmtnPointer==5) /* */ \
{ /* */ \

(*ePWM[ch1]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM1 */ \
(*ePWM[ch1]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM1 */ \
/* */ \
(*ePWM[ch2]).AQCSFRC.bit.CSFA = 2; /* Forcing a continuous High on output A of EPWM2 */ \
(*ePWM[ch2]).AQCSFRC.bit.CSFB = 1; /* Forcing a continuous Low on output B of EPWM2 */ \
/* */ \

/* (*ePWM[ch3]).AQCSFRC.bit.CSFA = 2;*/\
(*ePWM[ch3]).AQCSFRC.bit.CSFA = 0; /* Forcing disabled on output A of EPWM3 */ \
(*ePWM[ch3]).AQCTLA.bit.CAU = 1; /* Set high when CTR = CMPA on UP-count */ \
(*ePWM[ch3]).AQCTLA.bit.CAD = 2; /* Set low when CTR = Zero */ \
(*ePWM[ch3]).CMPA.half.CMPA = (int16)(Tmp1); /* PWM signal on output A of EPWM3 (Q15 -> Q0) */ \
(*ePWM[ch3]).AQCSFRC.bit.CSFB = 2; /* Forcing a continuous High on output B of EPWM3 */ \
}

#endif // __F2803X_BLDCPWM_H__