When you created the CW project, did you specify that floating point operations were required? This needs to be done in order to link the correct ANSI library file, that supports floating point operations.

However, since the PWMMC module is eventually loaded with 16-bit values, I would suspect that it should be possible to avoid the need for floating point calculations, and the conversion of floating point values to integer values, with the associated code size and timing penalties. The careful use of integer calculations should be able to maintain 16-bit precision.

It would seem that your calculation applies to a range of decimal values for ADC_IN of 764 to 2545.

Now consider the calculation -k = ADC_IN*9/.17820;Alternatively, this could be expressed as -k = ADC_IN*50.50505;This will give a calculated range 38586.8.. to 128535.3..

The next calculation k = -k+1.38585;will negate slightly reduced values.The next three calculations are similar to -PVAL1 = k * PHASE_A[TableIndex];

You have not revealed what values are in the table, and whether they are floating point or integer. However, my understanding is that PVALx variables provide an integer value. If a table value should exceed 0.254, it is possible for an overflow condition and an erroneous conversion from floating point.

I wonder if this is your problem. I also note that the calculated values are always negative (assuming table values are positive). Is this correct?Regards,Mac