Keil™, An ARM® Company

Technical Support

C251: TIMING AND DELAY FUNCTIONS

Information in this article applies to:

  • C251 Version 2.14

QUESTION

I am developing an embedded app in C and was wondering what you would suggest I use for timing? I need to delay execution from 5 to 10 microseconds in some instances. There are no built-in timing routines in the C251 compiler.

ANSWER

Here are 2 ways you may do this:

  1. Use the _nop_ () function to insert a number of NO-OP instructions into your C code. Figure out the amount of time it takes for a single NOP on your target and use as many as necessary.
  2. Create a function that starts a timer that generates an interrupt on overflow. The interrupt sets a flag that the function waits for after starting the timer. When the flag is set, the function stops the timer and returns.

Last Reviewed: Saturday, July 09, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure