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.

How can I set the exact delay time in microcontroller(at89c51)? (Keil)

Status
Not open for further replies.

buts101

Full Member level 3
Full Member level 3
Joined
Apr 29, 2005
Messages
168
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Activity points
2,867
Delay() in at89c51

how can i set the exact delay time in microcontroller(at89c51)...? delay() function of C is not support by keil compiler.
 

Unomano

Member level 1
Member level 1
Joined
Aug 31, 2005
Messages
40
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Location
Minsk, Belarus
Activity points
1,613
Re: Delay() in at89c51

Try this:
Code:
//------------------------------------------------------------------------------
//	Processing of Timer 0 interrupt request
//------------------------------------------------------------------------------
void Timer0(void) interrupt 1
{
	counter++;
	TH0 = TH_0;
	TL0 = TL_0;
	TF0 = 0;
}

//------------------------------------------------------------------------------
//	Generates Time*1/100 s delay
//------------------------------------------------------------------------------
void Delay(unsigned char Time)
{
	counter = 0;
	while(counter < Time);
}

if fOSC = 22.1184 MHz:
TL_0 = 0x00
TH_0 = 0xB8
it corresponds to 1/100 s overflow
 

wek

Full Member level 4
Full Member level 4
Joined
Dec 21, 2004
Messages
239
Helped
28
Reputation
56
Reaction score
2
Trophy points
1,298
Activity points
1,991
Delay() in at89c51

Unomano,

What's the purpose of setting TF to 0?

wek
 

tofinhk

Member level 1
Member level 1
Joined
Apr 6, 2004
Messages
36
Helped
6
Reputation
12
Reaction score
1
Trophy points
1,288
Activity points
380
Delay() in at89c51

TF0 should be the overflow flag
The timer will not continue if it is set. So you should clear TF0 to restart the timer.
 

deepanshu203

Newbie level 1
Newbie level 1
Joined
Jan 27, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,284
Re: Delay() in at89c51

Can't we try to use two for() loops in nested format for the same purpose?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top