Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Software delay calculation

Status
Not open for further replies.

Raveesh

Member level 2
Joined
Feb 6, 2011
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,564
Hi,
I just use the for loop to generate some delay , If I want to generate the delay particular intervals of time , how to do that ..?
Ex: frequency I'm using is 8MHz and one instruction will be 4 cycles.
void delay(int del)
{ int i=0;
for(i=0;i<del;i++;)
{

}
}

What will be the delay generated by the above code if the del=0xFFFF;

regards
Ravee
 

The delay will be different for each mcu with different architecture (PIC, AVR, ARM etc) and can even differ with different compilers.

Alex
 

And remember that software delays are likely to 'run slow' if your system uses any interrupts or 'cycle stealing' technology (such as DMA in a consumer PC).
 

Hi,
Can you tell, how to go with timer delay If I want a delays from 1ms to some second ..?
 

It would be very helpful to know the exact processor and compiler you are using. It appears you're using an 8MHz clock, but the other required details are missing from your posts.
 

I may be offtopic, but is not a good practice to use Delay to perform a wait function.
There is prefereable to use a timered interrupt flag instead.

This concept ( is not, but ) is somethink more close to multitask processing, sometimes called time slot.

+++
 

Hi,
I'm using MSP430 processor , and the compiler is IAR . I want to use the timer to generate the delay before calling few functions.

say I want to call some function after 100ms and some function after 50 ms , and all function will be called sequentially ..

regards
ravee
 

I, unfortunately, do not have an experience with the MSP430. However, I've uploaded a couple of appnotes, one of which deals with interrupt timers directly. The other is the C/C++ Manual for the MSP430, which has a interrupt timer example on page 116 and well as other places in the manual.

Here is a tutorial covering timers (Nov. 22) with several other links using the MSP430 and IAR Compiler:


MSP430 Tutorials

Hope this info helps you in your endeavor.
 

Attachments

  • MSP430-slap113.pdf
    1.6 MB · Views: 42
  • MSP430-slau132e.pdf
    704.1 KB · Views: 61

Hi,
I'm using MSP430 processor , and the compiler is IAR . I want to use the timer to generate the delay before calling few functions.

say I want to call some function after 100ms and some function after 50 ms , and all function will be called sequentially ..

regards
ravee

this fairly easy just go through the datasheet of your processor and study the timers and generate a timer interrupt for a common delay time e.g 1ms or 10 ms. then you can count the number of times the interrupt is been called and generate your required delay eg for a delay of 50 ms count 5 times if 10ms timer.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top