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.
 

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
 

Delay() in at89c51

Unomano,

What's the purpose of setting TF to 0?

wek
 

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.
 

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

Back
Top