[SOLVED] Problem with code for 1 sec delay in Keil compiler

Status
Not open for further replies.

rohini.embsystem

Newbie level 4
Joined
May 19, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
pune
Activity points
1,328
hi
i need 1 sec delay
i hv written the code like
void delay()
{
for(i=0;i<1275;i++)
for(j=0;j<20;j++);
}
it is giving me 1/2 sec delay.bt how to calculate it? m using keil compiler n controller is ATMEL 89C51. can anybody help me?
 

Re: delay for 1 sec

basically time delay is based on code optimization in Keil compiler (how it optimize the loops)

If you need accurate delay, it is better to use timers

read this application notes https://www.keil.com/appnotes/files/apnt_105.pdf
 
Re: delay for 1 sec

Hi,

What Crystal Frequency you are using?

Regards,
Viswanath
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…