#include<reg51.h> void delay() //Function to provide a time delay of approx. 1 second. Timer 1. { int i; for(i=0;i<20;i++) { TL1=0xFD; TH1=0x4B; TR1=1; while(TF1==0); TR1=0; TF1=0; } } void main() { char num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};// Hex values corresponding to digits 0 to 9 int c; while(1) { for(c=0;c<10;c++) { P1=num[c]; delay(); } } }
Hi guys, I am not getting delay of 1 sec.blinking rate of 7 segment is too fast in comparison of delay calculated(=1sec). Any help will be appreciated.. thanks
Not so sure the following text should be ignored:
In the ‘Timer’ function, the register is incremented every machine cycle. Thus, one can think of it as counting machine cycles. Since a machine cycle consists of six oscillator periods, the count rate is 1/6 of the oscillator frequency.
Above from chapter 7.3 of P89V51RD2 datasheet.
In the original post, we did not get to know the actual processor. We did not get to know the oscillator frequency. We did not get to know the used formula.
Not so easy to help if we don't get enough information.
I just used the formulae given in MAZIDI .
Mazdi refer to the old steam driven processors and thus Mazdi info should be taken with a BIG grain of salt when using modern processors.
per above my guess is that yur delay is 1/2 what you expect
Yes, that is how I interpret the details.
I don't understand how/why the OP changed my original talk of halving the delay and replied with the:
yes it is nearly double.
Must be one of those cases where I read it as I wanted to see it in my following response.
My favorite was the OPs statement:
but i think u read the datasheet incorrectly ...
As if he'd been reading and understanding it beforehand (faceslap)