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.

How to speed the code in msp430F47177 microcontroller

Other Parts Discussed in Thread: MSP430F47177

Dear All

I am using CCS5.2 compiler & doing  my application code in msp430F47177 microcontroller.In code there is large number of modulo & devide operations of float data types.So execute such float modulo & divide operation microprocessor requires more execution time & power.So please tell me how to improve my code.

Also if I transfer such code on to the ram then it will require less power which will improve the execution speed .But can any one tell me how to transfer such a code on to the RAM.

Thanking you,

With best regards,

Gokul Tile 

  • Gokul Tile said:
    there is large number of modulo & devide operations of float data types.So execute such float modulo & divide operation microprocessor requires more execution time

    So don't use floating point, then!!

    • With suitable scaling, you may be able to work entirely in integer maths; eg, instead of 1.23V, use 1230mV;
       
    • Have you considered fixed-point?

     

  • Andy Neil said:
    With suitable scaling, you may be able to work entirely in integer maths; eg, instead of 1.23V, use 1230mV;

    Indeed, that's by magnitudes faster. Also, often a formula can be optimized so it doesn't use division, or uses multiplication and a shift.
    Using float (or double) is in most cases totally unnecessary. What good is a result with 10 digits after decimal point if the error in the parameters in before the decimal point (and often not on the lowest digit).

    The only problem with scalign is that you need to take care of the possible value size in intermediate results. The formula must be reordered so that you never exceed the allowed value range. So firs tmultiply and hten divide, when dividing first would bring your value so low that the integer truncation removes valuable fractions. Or divide first, if the multiplication would exceed the int/long int range. It needs a bit 'brainwork', but but better spending some time at development than continuously wasting precious realtime cycles on unnecessary float operations.

  • Gokul Tile said:
    if I transfer such code on to the ram then it will require less power which will improve the execution speed

    Well, yes, running code from ram will reduce power consumption (the flash read process needs a little bit more than the ram read process), but it won't increase execution speed. One clock cycle is one clock cycle.

    This is different for FRAM devices (57xx/58xx/59xx). Here the FRAM has 8MHz maximum speed, so for MCU clock above 8MHz, one wait state is inserted at every FRAM read. Copying code to ram (and holding variables/stack in ram) makes a speed difference. However, these devices only have very few ram (2kB, IIRC)

**Attention** This is a public forum