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.

CCS/MSP430F2330: POWF function size

Part Number: MSP430F2330
Other Parts Discussed in Thread: MSPMATHLIB

Tool/software: Code Composer Studio

Hi,

we have an 8KB MSP430 using already 6.5KB and need to add the POW procedure from math.h. When we add it the FLASH usage jumps from 6.5KB to 10KB = no good for our small MSP430. Any suggestions?

Really can't understand how adding a single POW request adds 3.5KB?

Thanks,

Paul

  • Hi Paul,

    Two suggestions for you

    1. Write the pow function by yourself(It is not hard to realize)

    2. Optimize the code size

        some suggestions for this

        For CCS

       (1)Use small memory model for code@data as below

          

        (2)If possible, don’t use global variables. (Or use a very small number of global variables, and don’t have the pre-initialized. Initialize them inside of main. 

    )

        (3)In a project this small, you won’t have enough variables for the watchdog to time out before main and this to be a concern.

            Project > Properties > MSP430 Linker > Basic Options, set “Hold watchdog timer during cinit auto-initialization” to “off”

        (4)Set ALL globals as no-init using #pragma NOINIT, or use the CCS setting to disable zero-initialization (Project > Properties > MSP430 Linker > Advanced Options > Miscellaneous, set “Zero initialize ELF uninitialized sections” to “Off”)

    For IAR

      (1)Set the optimization of code size to high level. Project > Options > C/C++ Compiler > Optimizations   

      (2)Set both Code & Data Model to small memory model same with CCS

      

    (3)If possible, don’t use global variables. (Or use a very small number of global variables, and don’t have the pre-initialized. Initialize them inside of main. 

    )

    (4)Precede all global variables with the __no_init keyword, e.g. __no_init unsigned char RXData;  .

  • Thanks Gary,  we already have the optimisation set to small.  We found a piece of code we could use but it also uses 3.5KB, strange as it’s only about 15 lines. It used a union and doubles but we only actually need a version with floats as inputs. I was hoping to source a function that uses floats as that would hopefully reduce the size sisignificantly?

    It’s easy to write code for integer inputs but we need float inputs.

  • Hi Paul
    The math lib will take a big space of the memory, not strange for the 3.5KB. Two solutions for this case
    1. Convert the float data to integer
    I don't know where the data source come from(ADC or other communication interface), we can multiply the multiple of 10 (depend on your accuracy) with the source data to convert the float data to integer.
    2.i don't know whether you can change the device to F5XX/6XX or FRxx which with the MSPMATHLIB. And I suggest you can know about our new value line products which with low cost and powerful function. More information as below:
    www.ti.com/.../value-line-sensing-mcus.html
  • Hi Gary,

    its for a Gamma correction procedure/method and so we can live with 0.5 increments making coding simpler by do a square root. Would have been to btter to have more accuracy, ideally 0.1 steps but thems the breaks eh!

    Managed to get code from here: stackoverflow.com/.../computing-fractional-exponents-in-c

    and hacked it a little to do the job. Only uses another 300B this time so great.

    Thanks for you help.

**Attention** This is a public forum