Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

digital clock using 7 segment and 89c52, real time delay

Status
Not open for further replies.

tumee

Member level 1
Joined
Oct 26, 2007
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,508
I did digital clock using 7 segment and 89c52. But delay is incremented when clock hardware working. Its fall to behind about 4 second after 1 hour. If known anyone please tell me.
the delay code is:
void delay_asec(void)
{
unsigned char d;
for (d = 0; d < 20; d++){
delay_50ms();
}
}
void delay_50ms(void)
{
// SCON = 0x80;
//configure Timer 0 as a 16-bit timer
TMOD &= 0xf0; //Clear all T0 bits (T1 left unchanged)
TMOD |= 0x01; //Set required T0 bits (T1 left unchanged)
ET0 = 0; //No interrupts
//Values for 50ms delay
TH0 = 0x3c; //0x3c
TL0 = 0xb0; //0xb0
TF0 = 0; //Clear overflow flag
TR0 = 1; //Start timer 0
while (TF0 == 0); //Loop until 0 overflows (TF0 == 1)
TR0 = 0;
}
 

Re: help for real time delay

Delays generated by MCUs are rarely used as time-bases for clocks, so all what you can do is to play with the reload values for TL0 ..
In this instance, as the counter counts up and your cumulative time is to long, try to increase the value from #0B0h to #0B1h and see how it goes ..

Rgds,
IanP
 
Re: help for real time delay

Hi tumee,

Delay will be depend on crystal frequency that you used and in addition to that the other overhead/housekeeping commands.

I think you can use DS1307 real time clock IC to get very accurate delay time

bassa
 

Re: help for real time delay

Dear friend
I’m using ATMEL 89c52 using 11.059MHz
how to calculate delay in this routine?
DELAY:
mov temp1,#19h
lp1:
mov temp2,#19h
lp2:
nop
djnz temp2, lp2
djnz temp1, lp1
ret
 

help for real time delay - help needed

you may refer this link

#1256842
 

Re: help for real time delay - help needed

DELAY:
mov temp1,#19h - 1c
lp1:
mov temp2,#19h - 1c
lp2:
nop -1c
djnz temp2, lp2 -2c
djnz temp1, lp1 -2c
ret - 2c

19h=25

delay = (1c+ ( (1c + ( (1c +2c)*25) +2c)*25) + 2c) *1.085Micro S

regards
kj

Added after 2 minutes:

dear thothefali, please start your own thread next time.

regards
kj
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top