time delay for 1 minute

Status
Not open for further replies.

sankar mass

New Member
friends i need c program for 1 minute time delay for 8051 .

whether it is correct . i dont know how to calculate delay .

void delayms(unsigned int);
delayms(500);

void delayms(unsigned int n)
{
unsigned int i ,j;
for ( i=0;i<n;i++)
for(j=0;j<400;j++)
}
 
I'm no C programmer, but I note the delayms function takes n (the number of ms required) as an argument so can't you just call delayms(60000) ?
 
A quick compilation shows that the above loops are .. 6 instructions for the inner for loop and 12 for the outer for loop..

With a 12mhz clock the inner loop takes 2.4ms .. 6μs * 400 = so if n = 1 the total delay here is 2.4ms + 12μs + 4μs = 2.416mS.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…