Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/07/08 14:49
Read: times


 
#156480 - A common side effect of optimisation
Responding to: ???'s previous message

One thing I got tripped up on many years ago and I've seen many references to it is shared variables between interrupt code and main code. Without these variables declared as 'volatile' the compiler may decide to keep copies of the variable in registers as part of it's optimisation strategy. Turn off the optimisation and the code works, turn it on and it dies. Declare the shared variables as 'volatile', turn optimisation on and it works again.

Also, things like delay loops can get optimised out as the compiler figures out the variable is not used elsewhere. Again, coreect declaration of the variable tells the compiler what you want.


List of 22 messages in thread
TopicAuthorDate
Why Is Debugging Optimized Code Such an Issue?            01/01/70 00:00      
   Usually not            01/01/70 00:00      
      False Assumptions            01/01/70 00:00      
         "language specification" ??            01/01/70 00:00      
         Do not assume it is that easy            01/01/70 00:00      
            Common Stuff Leading To Errors            01/01/70 00:00      
               "common stuff" falling apart when optimized            01/01/70 00:00      
               How broken things work            01/01/70 00:00      
   It is not like that            01/01/70 00:00      
      A bad workman blames his tools            01/01/70 00:00      
         A common side effect of optimisation            01/01/70 00:00      
      Newbies            01/01/70 00:00      
   another good reason            01/01/70 00:00      
      a rule of thumb            01/01/70 00:00      
         excellent advice, however - and            01/01/70 00:00      
         Defeatist?            01/01/70 00:00      
            Or turn it down as needed            01/01/70 00:00      
               Using Pragmas During Debugging            01/01/70 00:00      
               Free lunch?            01/01/70 00:00      
                  a dream            01/01/70 00:00      
                     If it were easy everone would be doing it.            01/01/70 00:00      
            you can't            01/01/70 00:00      

Back to Subject List