Question asked by Susan li on Oct 25, 2017
Latest reply on Oct 26, 2017 by dumitru-daniel.popa
NXP expert,
Please help trouble shoot code(a function and its call) below. why I got dutyU, V & W all equal to zero?
And would please provide a piece of suggested code to calculate: 4000*(19661/65535), the 3 numbers for in all integers(uint16), and the result should be integer(uint16) too, for MPC5744P motor control using S32DS.
FLEXPWM_set_duty(19661, 19661, 19661);
tBool FLEXPWM_set_duty(tU16 x, tU16 y, tU16 z){
Â tU16 periodCarry, dutyU, dutyV, dutyW;
Â dutyU = x;
Â dutyV = y;
Â dutyW = z;
Â periodCarry = 4000;
Â dutyU = (tU16)MLIB_Mul((tFloat)periodCarry, (MLIB_Div_FLT((tFloat)dutyU,(tFloat)65535)));
Â dutyV = (tU16)MLIB_Mul((tFloat)periodCarry, (MLIB_Div_FLT((tFloat)dutyV,(tFloat)65535)));
Â dutyW = (tU16)MLIB_Mul((tFloat)periodCarry, (MLIB_Div_FLT((tFloat)dutyW,(tFloat)65535)));
at this point, I got dutyU, dutyV, dutyW all equal to zero, but I am expecting them all 1200.
return (TRUE);
}
thank you very much.
Susan Li