I am programming an ezdspF28335 using CCS V 3.3.8. I have noticed that when an unsigned/signed 16 bit multiplication tends to chop off the most significant byte in the result. Have any of you found the same? The problem is corrected only if the operands are typecast as Uint32/long. But why should that be done? Here is an example of what happens.
Uint16 variable1 = 0x8000;
int variable2=0x8000;
Uint32 Result1;
long Result2;
Result1 = variable1 * 0x400;
Result2 = variable2 * 0x400;
When this is run, the results in Result1 is 0x00000000 instead of 0x2000000, and Result2 is 0x00000000 instead of 0xFE000000. Clearly the MS Byte was truncated.
When type casting is done like this:
Result1 = (Uint32)variable1 * 0x400;
Result2 = (long)variable2 * 0x400;
The results in both variables are as expected (0x2000000 and 0xFE000000). Please let me know how to get the same results without having to cast.