please help trouble shoot code_S32DS for MPC5744P

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

please help trouble shoot code_S32DS for MPC5744P

501 Views
liwuquan
Contributor III
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
1 Reply

399 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

could you share your output file so I can test it?

From your description it is not possible to judge what is wrong.

Peter