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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/15/04 18:00
Read: times


 
#83176 - volatile.
Responding to: ???'s previous message
Quite frankly those typedefs are the result of the guidelines given by M.J.Pont in his Embedded C book. I somehow liked the concept and thought will use it.

Yes, the concept is very good - it's just the naming that lets it down.

You should define cntr_1, cntr_2 as volatile - otherwise the compiler may completely optimise this code away!


It is the optimiser's job to remove useless code that simply wastes time and/or code space.
These variables are never used within the loops, and never used again outside the loop - an optimising compiler is entitled to spot this and remove the apparently "useless" code.
By declaring the variables as 'volatile' you tell the optimiser that all is not as simple as it seems, so it will not remove code referencing them.

See your 'C' book for further details.


List of 22 messages in thread
TopicAuthorDate
Help LCD--89C51 using KEIL            01/01/70 00:00      
   RE            01/01/70 00:00      
   Keil?            01/01/70 00:00      
      Keil App Notes            01/01/70 00:00      
   Assembler programmer learning C?            01/01/70 00:00      
   So what happened to the USB, then?            01/01/70 00:00      
   The wanted code...            01/01/70 00:00      
      code            01/01/70 00:00      
         Tips and Tricks.....Andy            01/01/70 00:00      
            volatile.            01/01/70 00:00      
               Not so volatile ?            01/01/70 00:00      
                  optimiser            01/01/70 00:00      
                     Volatile warning?            01/01/70 00:00      
                        not here            01/01/70 00:00      
                        re: volatile            01/01/70 00:00      
                           volatile            01/01/70 00:00      
      Another comment - symbolic names            01/01/70 00:00      
   c code for lcd            01/01/70 00:00      
      code            01/01/70 00:00      
         symbolic Port names            01/01/70 00:00      
   There's Gratitude for you! :-(            01/01/70 00:00      
   A better method in C            01/01/70 00:00      

Back to Subject List