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.

TMS320F2812: The question about SPRC178 F281x PMSM3_3: Sensored FOC of PMSM Using Resolver

Part Number: TMS320F2812

In the peoject,we can find the document which is named as  f281xpwm.c.  

There is a function which is used for updating the PWM.The problem confused me.

Why is the p->PeriodMax   amplified to Q15?

At the begining of the function,the p->PeriodMax is  amplified to Q15.The Tmp is reduced to Q0.In my opinion,The EvaRegs.T1PR=p->PeriodMax.

It is not  necessary to amply  p->PeriodMax.The p->PeriodMax can make a assignment to The EvaRegs.T1PR directly.As a result,it can improve the efficiency.

The code like this:

void F281X_EV1_PWM_Update(PWMGEN *p)
{      
  int16 MPeriod;
        int32 Tmp;

// Compute the timer period (Q0) from the period modulation input (Q15)
        Tmp = (int32)p->PeriodMax*(int32)p->MfuncPeriod;           // Q15 = Q0*Q15
        MPeriod = (int16)(Tmp>>16) + (int16)(p->PeriodMax>>1);     // Q0 = (Q15->Q0)/2 + (Q0/2)
        EvaRegs.T1PR = MPeriod; 

....

}