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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/16/07 08:28
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#135084 - Well, any compiler with half a brain does that.
Responding to: ???'s previous message
for the avr only to discover that if you have an empty loop for timing and the loop can be shown to be finite and it has no other effects then gcc will remove the loop,<p>

That's called "Optimization".

There are some ways around it. If you can control the optimization level via #pragmas, you can just disable any optimizations for the loop. Alternatively, you can use intrinsic _nop_() functions, or twiddle a volatile variable. Or use inline assembly. Or write the delay function in assembly.

List of 19 messages in thread
TopicAuthorDate
akkkk! stupid compilers, something to watch            01/01/70 00:00      
   ehm, isn't it the user?            01/01/70 00:00      
      Well it might be phooey;- but its pretty common            01/01/70 00:00      
         have you considered using a timer, perhaps... :-)            01/01/70 00:00      
            yep but...            01/01/70 00:00      
               Sorry - not this time, Jez            01/01/70 00:00      
               if it is THAT short...            01/01/70 00:00      
                  Maybe not...            01/01/70 00:00      
                  Beware.            01/01/70 00:00      
   Well, any compiler with half a brain does that.            01/01/70 00:00      
      volatile            01/01/70 00:00      
   use util/delay.h and read the lib documents            01/01/70 00:00      
   optimization = lost control            01/01/70 00:00      
   well that is the first mistake            01/01/70 00:00      
      First mistake is using a HLL            01/01/70 00:00      
   Optimise & kill code            01/01/70 00:00      
      optimizers and NASA            01/01/70 00:00      
   There are many levels in Keil            01/01/70 00:00      
      not always a good idea            01/01/70 00:00      

Back to Subject List