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.

MSP430F2012 and Multiplication

Other Parts Discussed in Thread: MSP430F2012

Hi all,

This may seem like a silly question, but I wanted to know more about the warning message I receive in the following program (using MSP430F2012):

int test = 0;

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
int x = 5;
int y = 10;
int z = x*y;
test = z;
x = test;
} // BREAKPOINT HERE -- after everything happens

On the line where I try to make z, I get a warning that says: "#1533-D (ULP 6.1) Detected use of multiplication on a device that has no hardware multiplier" What exactly does that mean? Furthermore, when I run this program, all the way to the end at a breakpoint at the end, I try to observe what all of the variables contain. When I move my mouse over each of the variables -- to show what they are, it shows that x, z and test are all 50, which should be the case. However, for some reason y shows up to be 80. Would anyone know why that is and if it has to do with the multiplication warning?

There is another warning next to "int y = 10;" which says: #1535-D (ULP 8.1) variable "y" is used as a constant. Recommend declaring variable as either 'static const' or 'const'. Even more interesting is the fact that when I take out the line that assigns x to test, the line "int x = 5" gets the same warning as when y is assigned, however it still apparently ends up being 50 at the end of main (even without assigning it to test). Can anyone explain what is going on here, in particular, the significance of those two errors?

Any help would be greatly appreciated!

Thanks,
Matt 

  • Hi Matt,

    I always get these warnings, too. I think the one saying "#1533-D (ULP 6.1) Detected use of multiplication on a device that has no hardware multiplier" is to warn that multipication can take more cycles than other operations because to do it one needs 32 bit registers, as I googled. If your application does not require microsecond precision it is not something important I believe. (Opinion of a beginner :D)

    " #1535-D (ULP 8.1) variable "y" is used as a constant. Recommend declaring variable as either 'static const' or 'const'.": I made some 'googling' about differences between constants and variables. What I found is that declaring things do not change during the program execution should be done by using constants because it makes easier your coding, and prevents changes done by mistake. I thought there may be a difference between them in memorywise but could not found anything useful on the topic. But I still believe constants are better in memorywise until I got any disproof from experienced guys of the forum (: BTW you got the warning after erasing x = test because you make it remain unchanged  during the program. And compiler says you should declare it as a constant.

    Finally, and unfortunately, I have no idea how y can get a value of 80, and x gets 50 though you erase x = test. We should wait for superiors to help (:

    I know it contains too litte information respect to the post's length but hope it helped some of the questions at least.

    Regards,

    Gunay

  • Thanks for the post Gunay,

    It's definitely reassuring that multiplication will not completely fail, if I do end up needing it -- which is important to know and which was a main part of my question :)

    As for the changing values, I feel like it either has to do with the fact that test is a "global" (not technically global, but you know what I mean) variable which keeps it from changing randomly (because it may be needed elsewhere), and/or the fact that because the program knows that some variables such as y will never be used again, it can just change it (maybe it changed to 80 because it needed it somewhere else, idk). The program could have arbitrarily chosen y over another unused variable. If that is not the case, then I have no idea, and would love to hear an experts opinion on this :) Thanks for starting the discussion nevertheless Gunay :)

    Matt

  • Matthew Wasko said:
    I get a warning that says: "#1533-D (ULP 6.1) Detected use of multiplication on a device that has no hardware multiplier" What exactly does that mean?

    Have you seen the ULP Advisor - Rule Table on ULP Advisor which describes each rule?

    Matthew Wasko said:
    . When I move my mouse over each of the variables -- to show what they are, it shows that x, z and test are all 50, which should be the case. However, for some reason y shows up to be 80.

    With the default optimization level zero the compiler can store local variables in registers, which can cause confusing values to be displayed in the debugger if the register gets re-used for a different variable.

    The variables view in the CCS debugger shows which variables are in registers, and for which the displayed value may not be correct.

    In CCS Project Properties -> Build -> MSP430 Compiler -> Optimization setting the Optimization level to "off" which cause the local variables to be allocated on the stack and allow the debugger to view their value, but the at the possible expense of increased memory usage / slower code.

  • I didn't know where that ULP Advisor was. Very helpful, thanks for pointing that out to me, as well as for explaining the variables in registers thing.

    Matt

**Attention** This is a public forum