On 27-09-2006 at 18:07, peterwrigley wrote:
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.
Retrieving data ...