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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/07/06 18:01
Read: times


 
#121800 - on the subject of timing
Responding to: ???'s previous message
there are two ways of timing a)a loop and b) using a timer.

a1) in asm
a2) in C

b1) to set a flag
b2) to execute in the ISR

a1) will be precise except any ISR activity will add to the timing. Also, the uC can do nothing while the loop runs.

a2) will be very imprecise and any ISR activity will add to the timing. Also, the uC can do nothing while the loop runs. It can be used only in one case: I need a lot of delay, do not care how much, as long as it is a lot. One place where I gladly use a C 'delay' is in timeout loops. This is because these loops are never to time out except when something goes horribly wrong and thus can be set for some huge value to be 100 times the needed time and the likelyhood of a compiler revision changing that to 1 or less is minimal.

b1) will be precise except any ISR activity coinciding with the timer interrupt will add to the timing. The uC can run other things while waiting.

b2) will be precise except any ISR activity initiated before and coinciding with the timer interrupt will add to the timing (this can, if critical, be avoided by setting the timer interrupt to a higher priority). The uC can run other things while waiting. This method limits how much can be done at the 'time tick' since long ISRs are the bane of much.

Erik

more 'exotic flavors' exist e.g. using a PCA, but all are derivatives of the above.

List of 34 messages in thread
TopicAuthorDate
help with c51            01/01/70 00:00      
   Asking the impossible!            01/01/70 00:00      
   killing bad habits from the onset            01/01/70 00:00      
      Delay            01/01/70 00:00      
         Uncommented code is worthless!            01/01/70 00:00      
   No delay            01/01/70 00:00      
      I found this on the web.            01/01/70 00:00      
         Still not \"accurate\"            01/01/70 00:00      
            Sorry aaaaa more Accurate....            01/01/70 00:00      
   but why that weird inconsistency?            01/01/70 00:00      
      why wonder            01/01/70 00:00      
         what's fundamentally wrong on a delay loop?            01/01/70 00:00      
            to keep hacking at fundamentally wrong code serves            01/01/70 00:00      
               argggggggg!!! again.            01/01/70 00:00      
                  HUH?            01/01/70 00:00      
               still does not explain inconsistency            01/01/70 00:00      
                  to Jan            01/01/70 00:00      
               IS it time to put erik out to pasture            01/01/70 00:00      
                  there are many            01/01/70 00:00      
   The best way:            01/01/70 00:00      
   on the subject of timing            01/01/70 00:00      
      The Answer to the OP            01/01/70 00:00      
         Drive-By poster?            01/01/70 00:00      
            Oh how wonderful            01/01/70 00:00      
            Yes Drive-By Poster            01/01/70 00:00      
   char VS int            01/01/70 00:00      
      why do you persist            01/01/70 00:00      
         Learn through your mistakes            01/01/70 00:00      
            yes, I do            01/01/70 00:00      
               inline assembly in C            01/01/70 00:00      
                  sure            01/01/70 00:00      
                  why such figthing ?            01/01/70 00:00      
      write it out            01/01/70 00:00      
      debug            01/01/70 00:00      

Back to Subject List