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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/29/05 18:30
Read: times


 
#94094 - Software Delay Loops
Responding to: ???'s previous message
Vignesh:
Some have said that software loops in C are not predictable in terms of delay time.

I want to clarify that this is somewhat misleading to have this stated in this manner. The part that is unpredictable is when you compare the loop times you currently experience with those that are created when you process your c program software delay under conditions of the following types:

  1. Using a different version of the compiler to make your program's run time image.

  2. Using a compiler from a another vendor.

  3. Changing the memory model or optimization level of the compiler tool.

  4. Adding adjacent code in the source that somehow changes the optimization at compile time even though the same tool at the same settings were used.

  5. Running your code on an different hardware platform.

However.....all those issues aside there there are times when a software delay loop in C is a suitable and justified means to institute a delay in the code execution time. It is of course up to you to decide what is suitable when taking all of the above types of issues into account.

A very effective means to measure the time delay of a C code loop is to use a spare port bit as a singal flag. Set the bit as the time delay routine starts and clear it again after the delay routine is finished. Then use an oscilloscope to observe this resulting pulse on the spare port pin while the program is running. You can very quickly see exactly how long the delay is.

Michael Karas



List of 22 messages in thread
TopicAuthorDate
Keil: getting input            01/01/70 00:00      
   If it works in ASM it Works in C            01/01/70 00:00      
      Why C?!            01/01/70 00:00      
         Irrelevant            01/01/70 00:00      
         Of Course            01/01/70 00:00      
   key scan            01/01/70 00:00      
      Delay..            01/01/70 00:00      
         Delay            01/01/70 00:00      
         Software Delay Loops            01/01/70 00:00      
            Software Delay Loops            01/01/70 00:00      
   Learning 'C'            01/01/70 00:00      
   to be precise..            01/01/70 00:00      
      Debounce            01/01/70 00:00      
         completely missed it..            01/01/70 00:00      
      to be precise...            01/01/70 00:00      
         Sorry Leo !            01/01/70 00:00      
         Inferences            01/01/70 00:00      
            Right answer, wrong reason            01/01/70 00:00      
               and therefore            01/01/70 00:00      
            Congratulations            01/01/70 00:00      
               to: Raghu Sir            01/01/70 00:00      
      BIts!            01/01/70 00:00      

Back to Subject List