I am running the 28335 chip for 3 phase motor control. I am using the bldc motor control library originally designed for the 2808 chip. I am expecting a 20Khz PWM frequency and 150 MHz system clock. This indicates that the number of clock ticks per PWM period is 7500. My motor has a max speed of 28000 RPM. My expectation is that providing a 50% duty cycle (3750 clock ticks) to the PWM function should give me roughly 14000 RPM. When I look at the PWM function the calculation used is this:
// 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
{
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
EPwm1Regs.AQCSFRC.bit.CSFA = 0; // Forcing disabledd on output A of EPWM1
EPwm1Regs.AQCTLA.bit.CAU = 2; // Set high when CTR = CMPA on UP-count
EPwm1Regs.AQCTLA.bit.ZRO = 1; // Set low when CTR = Zero
EPwm1Regs.CMPA.half.CMPA = (int16)(Tmp>>15); // PWM signal on output A of EPWM1 (Q15 -> Q0)
EPwm1Regs.AQCSFRC.bit.CSFB = 1; // Forcing a continuous Low on output B of EPWM1
This indicates that the CMPA is setting the off time on the PWM and with the 50% I provided gave an off time of 6640 clock ticks leaving 860 clock ticks of on time. I am only getting 1/4 of the expected RPMs. Which makes sense to me since the on time is roughly 1/4.
What I can't figure out is what the calculation is trying to do. MfuncPeriod is 0x7fff.
My guess is that I am missing something fundamental about how this PWM library works but something just doesn't seem right to me. Can anyone clarify this for me? Thanks.