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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/25/05 06:01
Modified:
  10/25/05 06:02

Read: times


 
Msg Score: -1
 -2 Answer is Wrong
 +1 Good Answer/Helpful
#102881 - Yes you can...
Responding to: ???'s previous message
Erik Malund said:
I will suggest write the code in C only
some things can not be done in C. e.g. a release independent delay routine can not be wqritten in C. ANY C compiler may change the actual implementation of a C statement as long as the outcome is the same. E.g. if the compiler changes the implementation of "for ( ...; a>2345; ...)" from a subtract to a cjne the timing will change but no C rule has been violated.
Erik


Agreed...

But you can always check back the generated assembly code and decide the load count much closer to the required delay. This will definately give you the required delay with small + - tolerance.
example is
for(x=0;x<33000;x++);
will give you a precise delay of 1 sec.

If you want to work on each single instruction basis then it is not required to say that one has to use the language closer to hardware (Assembly)

If we take an example of keil compiler, it generates a fixed code for fixed conditional statements with same optimisation level. If you change or alter the level then the code is bound to change.

Now coming back to assembly "how precise is precise?" If you write a delay of 1 ms in assembly for a crystal 12 MHz (1 usec per instruction), you will get precise delay of 1ms, but it is difficult to get 1ms precise delay by 11.0592 (1.085 usec per instruction) MHz crystal.

To get altra precise delays in C you have an option to write it with an escape condition like timers. If you want them precise use timers, and if you don't then there is no question of going to assembly.

The moral is to write more challenging codes through C. It is ofcourse known from ages that we can write highly efficient codes via assembly, because it is microcontrollers own language. But doing it with C is great challenge.

Thank you.




List of 17 messages in thread
TopicAuthorDate
passing parameters from c to assembly            01/01/70 00:00      
   RTFM            01/01/70 00:00      
   What Compiler? They are all differerent            01/01/70 00:00      
   Why assembly???            01/01/70 00:00      
      some things can not be done in C            01/01/70 00:00      
         Yes you can...            01/01/70 00:00      
            Not true            01/01/70 00:00      
            eliminated            01/01/70 00:00      
            bull!            01/01/70 00:00      
         delay in C, yes !            01/01/70 00:00      
         More on 'C' delay loops...            01/01/70 00:00      
   sure, when you use a timer            01/01/70 00:00      
   Total Malund!            01/01/70 00:00      
      dear Russell re "bull"            01/01/70 00:00      
         Malund Bull...            01/01/70 00:00      
   Public variable            01/01/70 00:00      
   Examples...            01/01/70 00:00      

Back to Subject List