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.

24 bit multiplication- MSP430F6779A



Hi all,

I want to do multiplication of two 24 bit numbers. I am using SD24 ADC hence i am getting 24 bit data as output. for further calculations I have to do multiplication of two 24 bit numbers. so give me reply ,if anyone knows about this. It will be great help..

Thanks..

  • Hi Hemant!

    The simplest way for you would be a plain 32 bit x 32 bit multiplication:

    #include <stdint.h>
    
    uint32_t adc_result_1;
    uint32_t adc_result_2;
    uint64_t result_multiplication;
    
    result_multiplication = ((uint64_t) adc_result_1) * ((uint64_t) adc_result_2);

    It would be enough if one of the operands is 64 bits wide, so only one typecast would be OK, too. Or you declare one of the adc_result variables as 64 bits. But at least one of the operands has to be 64 bits, so the multiplication is done with 64 bits as well. Otherwise it will be calculated in 32 bits which will not work, of course.

    Dennis

  • Hi ,
    Use IQMath Library for fast multiplication. IQmpy Instruction for multiplication.

    Regards
    Bhavdipsinh
  • Hi Denis,

    I have to do 24 bit multiplication by using hardware multiplier, the multiplication has to be fast..

    my concern is, how it can be implemented...

    I have done it as below but it is not working.

    temp_mpy=(signed int long long)v1sd24value;
    MPYS32L=temp_mpy & 0xFFFF;
    MPYS32H=temp_mpy >>16;
    OP2L=temp_mpy & 0xFFFF;
    OP2H=temp_mpy >>16;
    MSB_temp_res=RES3;
    MSB_temp_res=(MSB_temp_res << 16)|(RES2);

    LSB_temp_res=RES1;
    LSB_temp_res=(LSB_temp_res <<16)| RES0;
    temp_res= (MSB_temp_res << 32) | LSB_temp_res;
    isq_sum_v1+=temp_res;  

    If you have any suggestions regarding above code then it will be helpful.

    Thanks..

  • A good compiler will automatically use the hardwar multiplier. Did you look at the code generated by the compiler?

**Attention** This is a public forum