| Author |
Message |
srinivasan2323
Joined: 05 Feb 2008 Posts: 25
|
19 Mar 2008 6:57 1sec delay program for 89c51 |
|
|
|
| hi i need a 1sec delay program for my 89c51 program
|
|
| Back to top |
|
 |
IanP
Joined: 05 Oct 2004 Posts: 6347 Helped: 1505 Location: West Coast
|
|
| Back to top |
|
 |
user1111
Joined: 24 Mar 2007 Posts: 25
|
26 Mar 2008 13:16 Re: 1sec delay program for 89c51 |
|
|
|
Ist make delay of 50ms using 16 bit timer
then call it 20 times
|
|
| Back to top |
|
 |
kcho
Joined: 12 Feb 2003 Posts: 29
|
25 Apr 2008 15:21 Re: 1sec delay program for 89c51 |
|
|
|
| how
|
|
| Back to top |
|
 |
ckshivaram
Joined: 21 Apr 2008 Posts: 327 Helped: 22 Location: india
|
13 May 2008 9:12 answer for your question |
|
|
|
Hi;
when u load 00 in 16 bit timer it takes 71.1msec to reach FF and overflow.
so 71.1msec *14times loop gives appx 995msec. for looping back in your program after overflow all corresponds to 1sec delay. So write a program with 00 in timer and repeat it for 14 times.
measure it you will get 1 sec delay.
write in assembly only not in C.
|
|
| Back to top |
|
 |
user1111
Joined: 24 Mar 2007 Posts: 25
|
20 May 2008 13:47 Re: 1sec delay program for 89c51 |
|
|
|
void delay1s(void){
unsigned char count = 50;
while(count>0){
TH0=183;
TL0=255;
TMOD=1;
TR0=1;
while(!TF0){
}
TF0=0;
TR0=0;
count--;
}
}
|
|
| Back to top |
|
 |
chandanghonmode10
Joined: 29 May 2008 Posts: 5
|
29 May 2008 13:14 Re: 1sec delay program for 89c51 |
|
|
|
| srinivasan2323 wrote: |
| hi i need a 1sec delay program for my 89c51 program |
Best way u use Timer insted of for loop for exact timing.
First u can load the value in 16 - bit timer for 50 ms. so loading the timer for 20 times,u will get exact 1 sec delay.
|
|
| Back to top |
|
 |
aderich
Joined: 03 Jun 2008 Posts: 8
|
05 Jun 2008 20:48 Re: 1sec delay program for 89c51 |
|
|
|
hi,
you can decide to use timers or a routine call
for instance,
mov r0,#4
mov r1,#250
mov r2,#250
lop:
nop
nop
djnz r1,$
djnz r2,$
djnz r0,lop
end
such program would give a isecond delay but alternatively one may decide to use the timers of the 89c51
|
|
| Back to top |
|
 |
jiraju
Joined: 06 Jun 2008 Posts: 11
|
06 Jun 2008 9:45 1sec delay program for 89c51 |
|
|
|
| first tell me the crystal value which u r using for system
|
|
| Back to top |
|
 |