Optimization settings for MPLAB

Discussion in 'General Electronics Chat' started by aamirali, Jul 15, 2014.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    I am using
    1. MPLAB V8.92.00.00
    2. Hi Tech C V9.82
    3. Compiler operation module - Pro

    What should be settings for:
    1. No optimization
    2. Default optimization
    3. Minimum size
    4. Maximum speed

    I am using below GUI interface for opt settings:

    MPLAB->Project->Build Options->Project->Compiler->Optimization settings (GUI for settings)

    Now What should be 'Global' value to be set '1 to 9' for space & speed.
    Should I tick/untick 'Assembler' options for speed and space
  2. aamirali

    Thread Starter Member

    Feb 2, 2012
    any help on that
  3. JohnInTX


    Jun 26, 2012
    I hope you haven't been waiting all this time :)

    I usually set the optimizations to maximum for a start. Speed vs space will add some inline code for speed or iterative loops for space. In my experience (in pre-OCG compilers) there isn't much difference, other than the space/speed code selection and even that isn't much.

    OCG compilers in the PRO mode are a different animal. OCG examines the whole program after linking to see what can be chopped out. Overall it works pretty well but you have to be aware that big chunks of code can be omitted and other code 'rewritten' so that debugging can be different than expected. If a source line can be optimized out, it won't be included and you can't set a breakpoint on it, even though its has a legitimate logical function. It takes some getting used to.

    Based on your optimize settings, I doesn't look like your version is OCG (I'm not sure where they added it - the README file should say) so set everything to max and see how it goes. As an experiment, compile with and without the various settings and compare code sizes. Pre-OCG, there won't be much difference.

    Good luck.

    EDIT Another Google search says OCG is present in the PRO mode so turn it on and give it a try. OCG is not available in the lite and standard (free and cheaper) modes.