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

Back to Subject List

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


 
#183298 - Side effects are always possible to make use of
Responding to: ???'s previous message
Erik Malund said:
DO NOT make (non-timer) delays in 'C' they may be optimized to zero

Erik

You can always make sure they are not optimized to zero, by giving them a side effect that the compiler is forced to honor.

But C delays not circling around a hardware-based timing construct should be avoided at any time where there is a hard requirement that a delay must have a minimum (or maximum) time. Withour making use of some known hardware for the timing, the C code will just result in a delay from an unknown sequence of instructions run a hard-coded number of times. And a developer can't know the time it takes for an unknown sequence of instructions to run.

A processor can have a large number of different ways to present the C code with timing feedback. A traditional timer is just one of them. It might be possible to read back information from a baudrate generator. Or abuse a unused SPI device for performing a dummy transfer. Or maybe there is a RTC.

List of 4 messages in thread
TopicAuthorDate
eeprom accessing problem            01/01/70 00:00      
   first problem            01/01/70 00:00      
      Side effects are always possible to make use of            01/01/70 00:00      
   Increment and Store            01/01/70 00:00      

Back to Subject List