TBPRD是这样定义的(*ePWM[ch1]).TBPRD = v.PeriodMax; 这个PeriodMax经过计算后的值为7500,所以halfpermax为7500/2 = 3750,,v.MfuncC1=0x4000,那这个PWM的占空比该如何计算呢
#define PWM_MACRO(ch1,ch2,ch3,v) \
\
/* Mfuncx range is (-1,1) */ \
/* The code below changes PeriodMax*Mfuncx range …. */ \
/* from (-PeriodMax,PeriodMax) to (0,PeriodMax) where HalfPerMax=PeriodMax/2 */ \
\
(*ePWM[ch1]).CMPA.half.CMPA = _IQmpy(v.HalfPerMax,v.MfuncC1)+ v.HalfPerMax; \
(*ePWM[ch2]).CMPA.half.CMPA = _IQmpy(v.HalfPerMax,v.MfuncC2)+ v.HalfPerMax; \
(*ePWM[ch3]).CMPA.half.CMPA = _IQmpy(v.HalfPerMax,v.MfuncC3)+ v.HalfPerMax; \
#endif
Wade zhang1:
求大神解答啊
TBPRD是这样定义的(*ePWM[ch1]).TBPRD = v.PeriodMax; 这个PeriodMax经过计算后的值为7500,所以halfpermax为7500/2 = 3750,,v.MfuncC1=0x4000,那这个PWM的占空比该如何计算呢
#define PWM_MACRO(ch1,ch2,ch3,v) \
\
/* Mfuncx range is (-1,1) */ \
/* The code below changes PeriodMax*Mfuncx range …. */ \
/* from (-PeriodMax,PeriodMax) to (0,PeriodMax) where HalfPerMax=PeriodMax/2 */ \
\
(*ePWM[ch1]).CMPA.half.CMPA = _IQmpy(v.HalfPerMax,v.MfuncC1)+ v.HalfPerMax; \
(*ePWM[ch2]).CMPA.half.CMPA = _IQmpy(v.HalfPerMax,v.MfuncC2)+ v.HalfPerMax; \
(*ePWM[ch3]).CMPA.half.CMPA = _IQmpy(v.HalfPerMax,v.MfuncC3)+ v.HalfPerMax; \
#endif
mangui zhang:
请参考
http://www.deyisupport.com/question_answer/microcontrollers/c2000/f/56/t/25828.aspx