Microcontroller › 8051 › question about digital clock project posted here. › hello romel, How does the
hello romel,
How does the code you have pased above (which which given on site) is giving 1 second…
timer register is a 16 bit register since they are using it in mode1
TH1=0x4B;
TL1=0xFD;
so 4BFD = 19453 in decimal
65535 – 19453 = 46083;
they using 12MHz crystal so freq./12clock
12MH/12=1Mhz
t=1/f=1 us in the case of 12 MHz crystal
if they would have used 11.0592 Mhz it would be 1.085 us
46083*1us*20 loops= 921660 us near about 0.92 second for 12Mhz
46083*1.085us*20 loops= 1000001.1 micro second which is more closer to 1 second
ideally they would have used or calculated it for 11.0592Mhz
and the delay function(second one) which you have pasted will count = 49999 us*k (according to 12Mhz)
if k=20 the total it will give around 0.99 second… so you delay in case of 12 Mhz will be more accurate..