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.

Hi, can MSP430g2553 perform multiplication?

Other Parts Discussed in Thread: MSP430G2553

I need to multiply variables (outputs from the  sensors) with some constants. I am aware that msp430g2553 lacks a hardware multiplier? does it have a problem while raising interrupts?

  • Yes, of course it can multiply things. It can do all the math you want.

    Dennis
  • Vasuki Shankar said:
    I need to multiply variables (outputs from the  sensors) with some constants. I am aware that msp430g2553 lacks a hardware multiplier?

     Uhm.. I think old Zuse electromechanics computer where able to do multiplication without specialized hardware multiplier.. why modern electronic one cannot do?

    http://www.german-way.com/notable-people/featured-bios/konrad-zuse/

    Vasuki Shankar said:
    does it have a problem while raising interrupts?

     Why?

  • Vasuki Shankar said:
    does it have a problem while raising interrupts?

    The MSP430G2553 doesn’t have problems when and Interrupt has been served, this applies only to devices with a Hardware Multiplier, the MSP430Gxxx doesn’t have this.

  • Leo Bosch said:
    The MSP430G2553 doesn’t have problems when and Interrupt has been served, this applies only to devices with a Hardware Multiplier, the MSP430Gxxx doesn’t have this.

     Hi Leo I think probably what mean interrupt question but this has to be answered from Vasuki than you, did you mean problem of protecting resource so to save Multiplier state before use on interrupt then restore before leave? Compiler provide protection about this and handling of MAC unit is done on choice.

     My usage of MAC was generally only on interrupt and DMA to parallel filtering task of multiply accumulate, this feaure is MSP unique and I moved some DSP code to MSP. This was in the past, age is progressing and time go away too fast for me. All new generation are too fast food Arduino like poisoned to learn about how to do special math with less power.

  • Hey Roberto,

    What I was wondering was does msp430 have problems while performing complex multiplication while servicing interrupts? as it doesnt have a MAC unit, can it store the large intermediate result mean while?

    Vasuki
  • Vasuki Shankar said:
    as it doesnt have a MAC unit, can it store the large intermediate result mean while?

     I am not able to understand what this mean....

     Anyway MAC unit is not part of ALU but it is a peripheral so it is treated as shareable resurce and must be protected from concurrent access by programs. When one program is using this resource load some value to MAC registers and if get interrupted by some process this new process can load new values voiding preceding operation and giving erroneous result to background main program flow...

     This is why MSC resourec has to be protected with some primitive like semaphore or status completely saved and restored when used on interrupt.

  • Thanks all for the reply.
    I faced some problems while multiplying large constants as the program wouldnt run citing excess memory usage issues. How can we tackle this?

    Thnks
  • Vasuki Shankar said:

    I need to multiply variables (outputs from the  sensors) with some constants. I am aware that msp430g2553 lacks a hardware multiplier? ...

    Correct. Thus multiply must be carried out in software. If you use c, there are lots of library functions to do integer as well as floating point multiplications

    Vasuki Shankar said:

    .. does it have a problem while raising interrupts?

    There is no problem for MSP430G2553. But the library functions may have problems if you use them both inside and outside of your ISR. Also, you may run out of memory or time.

    To multiply a variable with a constant in software can be carried out with Horner's method efficiently. But your c-compiler may not apply that.

  • It's quite uncommon for simple math functions to use global variables, so there shouldn't be any conflict for using them inside or outside an ISR a the same time. However, stack space could be an issue.

    In any case, when multiplying, keep an eye on the value range of the used data.
    300*300 doesn't give 90000, it will give 24464 because both values are int values, so the result will be truncated to int value range too, even if you then assign it to a long int variable.

**Attention** This is a public forum