Hello,
I am writing an application for computing power on MSP430F4784. IDE is CCSv5.4.
Signed multiplication is performed using 16 x 16 hardware multiplier peripheral.
Following formula computes power:
UkArray[0][index] = Uk;
IkAvg[0][index] = ((signed int)((((signed int)(Ik)) + ((signed int)(Iold))) >> 1));
MPYS = UkArray[0][index];
OP2 = IkAvg[0][index];
PkAvg[0][index] = ((signed long)(((signed long)(RESHI << 16)) | ((signed long)(RESLO))));
After compiling the program, i am getting following warning:
#64-D shift count is too large
Results observed in hardware multiplier result registers RESHI and RESLO are correct.
But results stored in array variable PkAvg[0][index] are wrong.
e.g., MPY = -8520
OP2 = -2052
RESHI = 0x010A -- This is correct
RESLO = 0xC520 -- This is correct
However, PkAvg[0][index] = 528240 -- This is wrong
16 x 16 signed multiplier is calculating correct results, but why is the compiler storing wrong results in array variable PkAvg[0][index] even after type casting RESHI and RESLO to signed long which is 32 bits ?
Thank You,
Sunil