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.

Floating Point: MSP432 only 3x faster than MSP430?

Other Parts Discussed in Thread: MSP430F2410

I'm considering migrating from the MSP430F2410 to the MSP432p401R.

I'm trying to compare the floating point performance between the two processors. I'm using IAR for both processors.

On the MSP432 I'm running this loop:

float ans;
float op;

while(1)
{
// Toggle P1.0 output
GPIO_toggleOutputOnPin(
GPIO_PORT_P1,
GPIO_PIN0
);

ans = 0;
//each loop should be 1000 cycles
while(ans < 3141.0)
{
//p2.7 is pulled low
if(GPIO_getInputPinValue(GPIO_PORT_P2,GPIO_PIN7) == 0x80)
{
op = 0;
}
else
op = 1.0;
ans = ans + 3.141 * op;
}

}

On the MSP430 I'm running the same algorithm:

while(1)
{
// Toggle P1.0 output
P1OUT ^= BIT0;


ans = 0;
//each loop should be 1000 cycles
while(ans < 3141.0)
{
//P6.6 is pulled low
if(P6IN & BIT6 == BIT6)
{
op = 0;
}
else
op = 1.0;
ans = ans + 3.141* op;
}

}

I'm probing the LED output on both boards with an oscilloscope. The high cycle time for MSP430 is 27.2ms and the high cycle time for MSP432 is 9.5ms. So MSP432 is running ~3x faster. This is suspiciously similiar to the ratio of their clocks (48MHZ vs 16Mhz)

The MSP432 should be much faster because of the FPU, right? Perhaps I don't have the FPU enabled correctly?

Is there an example of how to boost the performance? How can I know for sure that I'm using the floating point hardware?

Thanks!

  • Perhaps you would want to read this comment and thread as such: e2e.ti.com/.../1470908
  • ADAM ROTHROCK said:
    The MSP432 should be much faster because of the FPU, right? Perhaps I don't have the FPU enabled correctly?

    The FPU in the Cortex-M4F MSP432 can only handle 32-bit (single) precision.

    Any 64-bit (double) precision operations cause software routines to be called instead of using the hardware FPU.

    In your example floating point constants such as 3.141 are as per the C standard treated as double precision, which causes the compiler to perform double precision calculation using software routines.

    If you add a "f" suffix to such constants the constants become single precision and the compiler can then use the hardware FPU.

    Looking at the generated assembler for your example showed the compiler calling software routines.

    When if was changed to make the constants single precision then the compiler generated hardware FPU instructions instead:

        float ans;
        float op;
    
        while(1)
        {
        // Toggle P1.0 output
        GPIO_toggleOutputOnPin(
        GPIO_PORT_P1,
        GPIO_PIN0
        );
    
        ans = 0;
        //each loop should be 1000 cycles
        while(ans < 3141.0f)
        {
        //p2.7 is pulled low
        if(GPIO_getInputPinValue(GPIO_PORT_P2,GPIO_PIN7) == 0x80)
        {
        op = 0;
        }
        else
        op = 1.0f;
        ans = ans + 3.141f * op;
        }
    
        }
    

    I haven't timed this updated example, but from looking at the difference in the generated assembler it should be faster [assuming it is acceptable for your results to be calculated entirely using single-precision].

  • Thanks for your help! I forced the constants to single precision as you suggested. Now I can also confirm (from assembly code) that the floating point instructions are actually being used.

    Now for the LED high cycle times:
    MSP430: 27.2ms
    MSP432: 1.8ms

    So now the MSP432 is roughly 15x faster--much better.

    Thanks Again!

**Attention** This is a public forum