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.

I need program for delay in C for mcu

Status
Not open for further replies.

gsb_khan

Newbie level 1
Joined
Jan 18, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
programming in c for mcu

can u provide correct program for delay with formulae in embedded c
 

banh

Advanced Member level 1
Joined
Dec 16, 2004
Messages
458
Helped
17
Reputation
34
Reaction score
5
Trophy points
1,298
Activity points
3,937
programming in c for mcu

you can use simple for loop
unsigned int i;
for (i=0; i<0xFFFF; i++);

note that the above delay is only estimation, and depends on many factors such as compiler optimization. if the compiler optimization is turned on it may ignore the loop..

another way for delay is probably to use the timer of your MCU. this can achieve more accurate delay as you wish.
 

metal

Full Member level 6
Joined
Dec 21, 2004
Messages
364
Helped
19
Reputation
38
Reaction score
6
Trophy points
1,298
Activity points
3,833
Re: programming in c for mcu

Hi

If you are using CCS, you can do the following:

#use delay(clock=4000000) // Define the crystal speed here

then you can use:

Delay_Us(100);
or
Delay_Ms(10);

For example...

Good luck
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top