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.

TMS320F28069M: Effect of optimization on embedded code

Part Number: TMS320F28069M


Folks,

Have a question on enabling optimizations in our control code.

We do the "usual" stuff in our control code, read ports, perform ADC, perform operations on the input variables and set a few ports to actuate physical actions. A typical embedded control system.

Question is, What is the effect on optimization on the code ? What optimizations are recommended and what are not ?

My irrational worry is that if I enable aggressive optimizations it might optimize away seemingly useless code but which might be very important. Any rules of thumb here ?

We are now constrained only on time, code space is not an issue.

Thanks. -Bhaktha

  • Bhaktha,

    The 'volatile' keyword should be used when declaring pointers to hardware registers.  This forces the compiler to do what you code, and keeps it from optimizing away that code.  If you are using the TI bit field structures, the structures are already declared as volatile.  If you declare any additional pointers or data structures, you should use volatile.

    Regards,

    David