Aug 18, 2010 #1 R 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?
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?
Aug 18, 2010 #2 bassa Super Moderator Staff member Joined Jul 15, 2007 Messages 1,815 Helped 191 Reputation 402 Reaction score 156 Trophy points 1,353 Location Sri Lanka Activity points 11,261 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 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
Aug 19, 2010 #3 Y yviswanathbe Full Member level 4 Joined Jun 14, 2007 Messages 221 Helped 10 Reputation 20 Reaction score 6 Trophy points 1,298 Activity points 3,066 Re: delay for 1 sec Hi, What Crystal Frequency you are using? Regards, Viswanath