void F281X_EV1_BLDC_PWM_Update(PWMGEN *p){
int32 Tmp;
int16 Period, GPR0_BLDC_PWM;
// State s1: current flows to motor windings from phase A->B, de-energized phase = C
if (p->CmtnPointer==0)
EvaRegs.ACTRA.all = 0x00C2;
// State s2: current flows to motor windings from phase A->C, de-energized phase = B
else if (p->CmtnPointer==1) EvaRegs.ACTRA.all = 0x0C02;
// State s3: current flows to motor windings from phase B->C, de-energized phase = A
else if (p->CmtnPointer==2) EvaRegs.ACTRA.all = 0x0C20;
// State s4: current flows to motor windings from phase B->A, de-energized phase = C
else if (p->CmtnPointer==3) EvaRegs.ACTRA.all = 0x002C;
// State s5: current flows to motor windings from phase C->A, de-energized phase = B
else if (p->CmtnPointer==4) EvaRegs.ACTRA.all = 0x020C;
// State s6: current flows to motor windings from phase C->B, de-energized phase = A
else if (p->CmtnPointer==5) EvaRegs.ACTRA.all = 0x02C0;
// Convert "Period" (Q15) modulation function to Q0
Tmp = (int32)p->PeriodMax*(int32)p->MfuncPeriod; // Q15 = Q0*Q15
Period = (int16)(Tmp>>15); // Q15 -> Q0 (Period)
// Check PwmActive setting
if (p->PwmActive==1) // PWM active high,如果PWM调制在ACTRA设置为高电平有效时,则占空比需要进行下一步运算。
GPR0_BLDC_PWM = 0x7FFF – p->DutyFunc; else if (p->PwmActive==0) // PWM active low
GPR0_BLDC_PWM = p->DutyFunc;
// Convert "DutyFunc" or "GPR0_BLDC_PWM" (Q15) duty modulation function to Q0
Tmp = (int32)Period*(int32)GPR0_BLDC_PWM; // Q15 = Q0*Q15
EvaRegs.CMPR1 = (int16)(Tmp>>15); // Q15 -> Q0
EvaRegs.CMPR2 = (int16)(Tmp>>15); // Q15 -> Q0
EvaRegs.CMPR3 = (int16)(Tmp>>15); // Q15 -> Q0
}
Shine:
DSP28xx的问题有专门的C2000论坛,请到下面的咨询更快捷。
e2echina.ti.com/…/
user5213609:
回复 Shine:
好的,谢谢老师