cancel
Showing results for 
Search instead for 
Did you mean: 

Delay

ajsndd
Associate II
Posted on September 27, 2006 at 14:37

Delay

2 REPLIES 2
ajsndd
Associate II
Posted on September 27, 2006 at 12:19

Sir,

Here I am using STDV710B evaluation board.I am trying to write a function for Delay as shown below. What should be the delay in Microsecond while executing this function.

Delay()

{

__asm(''NOP'');

}

pete3
Associate II
Posted on September 27, 2006 at 14:37

One cycle will be used to execute a NOP.

The precise length of time will depend on the CPU operating frequency, which will depend on the PLL status and the crystal used.

The compiler may optimise out your instruction, which would give no delay as the function would not be executed. Overhead will be generated in calling the function and in returning from it. The precise overhead will depend on the calling conventions of your compiler (look at the disassembly listing).

Whether or not you are using Thumb mode may have an effect.

Personally I would configure the PLL then use a timer to generate a delay. You can then set a bit to flag to the rest of the application that ''something needs done'' or do small calculations in the interrupt routine. This is actually easier! Also note you can configure the hardware to automatically do things on counter matches; if you need to output a square wave (say to measure the frequency) the PWM, OPM or OCMP modes should be of use to you. These also have the advantage that the CPU does not intervene so the value you load into the timer module will have a direct relationship with the length of any output pulse.