MSPGCC Code optimization Problem

Shoaib Ali
  • Shoaib Ali

    Shoaib Ali - 2008-01-16

    Hi.. I am using MSP430F169 (code memory 60K) and using MSPGCC with Eclipse for code development. I have developed the code with Optimization Level O0 and code memory used is 58K. When I change the optimization level to O2 code size reduces to 42K but it does not work properly. It does not work with any other optimization levels. The reason for using No optimization initially was to make debugging easy. So, now, I am kind of stuck as to how could I make it work with Optimization level O2 as I am running out of code space, Kindly help. Regards

    • Jeliazko Batchvarov

      try is declaring all variables as "volatile". Later you will have to decide exactly which ones have to be ...

      I assume you have modular code - try testing each module separately with a test main() function. Examine the assembly code and look for missing loops/if/else etc. statements.

      I also assume that you have 0 warnings after compilation. If you don't - fix these first. I recently had an argument with a colleague over his code. The compiler was complaining more than 100 times. He was using bitwise instead of logical operations in if() statements. He was arguing that these produce the same end result (which they did but the compiler generated different code for arithmetic and logical operations). The code did not fit in 16kB with >1kB over the limit. After fixing the if()'s the code fit in the memory without optimization.



      • Shoaib Ali

        Shoaib Ali - 2008-01-28

        Well.. I have found the problem and is fixed now..:)... By changing optimization level it didn't only reduce code size but had also optimized for speed as well... There was a bit time error in one of the SPI interfaces as a result of optimization... Thanks for all your help
        Kind Regards


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks