This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430G2553: Variable multiplication giving false output

Part Number: MSP430G2553


Tool/software: Code Composer Studio

I want to multiply two ADC readings (voltage and current to get power). I am using CCS7 version and I enabled the hardware multiplier in CCS project properties, compiler and linker(set to 16).

But the result in the watch window is nowhere near the actual answer. If I try to multiply two variables, the result i am getting is '314' for any value of the variables. And if try to multiply one variable(value 45) with a constant, i can not increase the value of the constant more than the number 32, when ever it goes more than 32, the result becomes '314'. If I multiply two constant numbers, whose product is less than 32768, i am getting the right answer.

Am I missing any settings..??

The variable declaration and multiplication portion is as given below

unsigned int adc_val[6]={0,0,0,0,0,0};
unsigned int v_pan_avg_acc_n10=0,c_pan_avg_acc_n10=0,v_pan_avg_n7=0,c_pan_avg_n7=0;
unsigned int panel_pwr_n14=0;

------------------------------------------------------

-----------------------------------------------------

v_pan_avg_acc_n10   = v_pan_avg_acc_n10+adc_val[4];

c_pan_avg_acc_n10   = c_pan_avg_acc_n10+adc_val[1];

adc_count++;

if(adc_count>32)
{

v_pan_avg_n7 = v_pan_avg_acc_n10>>8;
....................................................................
c_pan_avg_n7   = c_pan_avg_acc_n10>>8;

panel_pwr_n14 = (v_pan_avg_n7) * (c_pan_avg_n7 );

..................................................................

.................................................................

}

**Attention** This is a public forum