Keil Logo

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 9, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.