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.

[SOLVED] code for AT89S52 timer1 to generate delay rolls faster than expected

Status
Not open for further replies.

papunblg

Advanced Member level 3
Joined
Oct 22, 2010
Messages
716
Helped
172
Reputation
344
Reaction score
165
Trophy points
1,343
Location
Kolkata India
Activity points
6,421
I need to generate 1 sec delay. I use the following code. AT89S52 with 12MHZ XTAL. Number of counts C3F4(49,999) + 1.
But P2.1 going high in less than 1 sec.

ORG 0000H

STT: MOV R0,#20
MOV TMOD,#10H
AGAIN: MOV TL1,#4FH
MOV TH1,#0C3H
SETB TR1
BACK: JNB TF1,BACK
CLR TF1
CLR TR1
DJNZ R0,AGAIN
CPL P2.1
SJMP STT
END
 

write this code it will generate the delay of 1.06 sec

ORG 0000H

STT: MOV R0,#15
MOV TMOD,#10H
AGAIN: MOV TL1,#0
MOV TH1,#0
SETB TR1
BACK: JNB TF1,BACK
CLR TF1
CLR TR1
DJNZ R0,AGAIN
CPL P2.1
SJMP STT
END
 

Thanks for your try. But I need 1 sec delay. Your code is giving 1.9s with 12Mhz xtal.

I myself have solved the problem. My formula to calculate the delay was wrong. Th1 should be 3CH and Tl1 should be B1H
Thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top