S sankar mass New Member Mar 13, 2013 #1 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++) }
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++) }
alec_t Well-Known Member Most Helpful Member Mar 13, 2013 #2 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) ?
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) ?
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Mar 13, 2013 #3 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.
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.