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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Jan Waclawek
01/04/08 09:54
  01/04/08 09:55

Read: 1064 times

#149050 - fixed delay
Responding to: Erik Malund's previous message
In 99.9% of programs a delay function is called with a constant parameter; and in 99% of those there are no more than a couple of constants used, and in 99% of those only one or two of them need to be that precise.

In other words, the flexibility of that routine is very rarely justified, it's usually just the laziness of the programmer who wants such delay pre-chewed and easy to use, rather than write one ad-hoc for each case.

Erik Malund said:
However I can think of a few cases where the solution proposed by Russ will apply, for instance in cached processors you will not have to take (possible) cache misses into account.

I don't see the point. I believe the jump-caching processor such as the fast silabs-s and upsd3xxx-s cache the "jmp @a+dptr"-s, too, so you have the same degree of uncertainty in using this method as in a djnz loop.

Only a "linear" set of NOPs inline with the rest of code (no call/ret either) will ensure you deterministic results in a jump-caching processor (or cache exclusions and/or locks, AFAIK the latter is the option for the silabs).

In a "general-caching" processor, there is no hope for precise timing, of course, (except again for cache exclusions or locks).


List of 27 messages in thread
Number of CPU cycle for 8051 function call      Jae-yong Kim      01/04/08 01:03      
   Do it in assembler      Andy Neil      01/04/08 03:00      
   Delay functions      Andy Neil      01/04/08 03:07      
   A related trick        Russ Cooper      01/04/08 05:56      
      Offset      Andy Neil      01/04/08 07:03      
         Offset      Russ Cooper      01/04/08 07:23      
            Sure      Andy Neil      01/04/08 07:40      
               Over Drive?      Neil Kurzman      01/04/08 10:20      
      a refinement      Erik Malund      01/04/08 07:58      
      NOPs are so bad waste of space...      Jan Waclawek      01/04/08 08:51      
         waste of space... waste of time      Erik Malund      01/04/08 09:24      
            fixed delay      Jan Waclawek      01/04/08 09:54      
               Variable delay      Russ Cooper      01/04/08 11:04      
                  determinism of the cache      Jan Waclawek      01/04/08 11:36      
               there are no cache misses in 'linear code'      Erik Malund      01/04/08 11:16      
                  I got only ONE cache miss...      Jan Waclawek      01/04/08 11:39      
      Old Keil Thread      Jon Ward      01/06/08 18:29      
   What about a Delay like this.      Jerry Black      01/07/08 05:31      
      No, it won't.        Christoph Franck      01/07/08 05:55      
         Ok.      Jerry Black      01/07/08 07:08      
         also      Erik Malund      01/08/08 06:47      
      Also ...      Christoph Franck      01/08/08 07:01      
         Actually...      Brett Wallace      01/08/08 08:02      
            will.      Jerry Black      01/08/08 08:21      
               ANSI C      Maarten Brock      01/10/08 05:58      
                  Keil option: Disable ANSI casts      Andy Neil      01/10/08 07:08      
         typo.      Jerry Black      01/08/08 08:24      

Back to Subject List