ARM Technical Support Knowledge Articles

TIMING AND DELAY FUNCTIONS

Applies to: C251 C Compiler

Answer

Information in this article applies to:


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.

Article last edited on: 2005-07-09 11:28:53

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential