how to create a delay?
Fri, 03/27/2009 - 19:35
I am using DS89C240 ( Dallas) microcontroller. Can you tell me how to create the exact delay of .25s.

bOtskOOl website by bOtskOOl is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License.
Permissions beyond the scope of this license may be available at http://www.botskool.com/contact.
bOtskOOl.com Privacy Policy - bOt-Xchange Product Listing Policy - Intellectual Property Rights (IPR) Protection Policy

What is the frequency of the crystal being used by you?
11.0592MHz
if you are using a 11.0592 MHz crystal then this program will create a delay of approximately 250ms
DELAY:MOV R1, #200
MOV R2, #139
MOV R3, #250
N1: DJNZ R3,N1
N2: DJNZ R2,N2
N3: DJNZ R1,N3
RET ; return to the caller
(in assembly language)
In Kiel C
void MSDelay (unsigned int itime)
{
unsigned int i,j,k; // where itime is time in mili second
for(i=0;i<250;i++)
for (j=0;j<9;j++)
for(k=0; k<139; k++);
}
Ankit, try to understand the logic behind the creation of that delay. Every instruction will take some time time to execute. In both the programs we explore that same feature. we load Registers R1,R2,R3 with some values, let them decrement and check with a condition. If they fullfill the condition let them move on, if not then jump to specified branch. Here the conditions is to check for zero. This way you can create delays, but here is the catch, to create delays we are considering the execution time of a single instruction. Different controllers have different execution speed, The Dallas DS89 series has a higher than it's counterparts.
do anybody have any idea about setting delay for LCD programming.
This query has already been answered in a different post. Follow this link.
Assembly Program:
ORG 0
MOV A, #55H
AGAIN: MOV P0, A
ACALL DELAY
CPL A
SJMP AGAIN
DELAY: MOV R2, #7
HERE1: MOV R1, #255
HERE2: MOV R0, #255
HERE3: DJNZ R0, HERE3
DJNZ R1, HERE2
DJNZ R2, HERE1
RET
END
Delay Calculation:
Crystal used= 4 MHz
Clocks per machine cycle for 8051 = 12
Machine cycle frequency = (Crystal Frequency) / (Clocks per machine cycle)
= 4/12
= 0.3333 MHz
Time Period of Machine Cycle = 1/0.33
= 3.003us (microseconds)
No. of machine cycles = 1(for MOV A, #55H) + 1(for MOV P0, A)
= 2 cycles
Total Delay = 7 * 255 * 255 * 2 * 3.003
= 2733781.05us
= 2.73 seconds
Small applications, in wat way we should select a suitable IC.... For example in Wireless Switch circuit IC 3410 ic was used.... This circuit given by our EFY..... I m like to know how they select this IC..... I m waitin for ur great reply..
Dinesh your question is not clear, Please explain your problem in detail. Switch to a new thread
Hello sir,
I want to learn about circuit design and want to know full details about IC .... So please suggest me a good website and good book for me.... It will help me alot... I am waiting for your great reply.... Thanking you...
Hello Dinesh,
The world of iC is quite large & we too are ever learning
You should be specific about the thing you wish to study
I will suggest you to start with microcontrollers and while you go for intefacing with things like motors, LCD, wireless, or even if you try project like making a digital thermometer you shall learn that to do anything in electronics you have an IC
Just try reading some projects or tutorials on this site (hope you have basic electronics knowledge) and you shall learna s you go...
Best of Luck
Keep discussing bro
http://www.botskool.com/tutorials/electronics/general-electronics/motor-...
http://www.botskool.com/tutorials/electronics/8051/introduction-8051-ass...
(8051 is the most basic microcontroller start with it)
You can also refer to Majdi for 8051 refrence, it is an excellent book!!
Can anybody could provide me the hex code for the above assembly code
ROBOTS ARE MY HEART
you can generate it in UMPS demo software..
what header do i use 4 assembly language to include the device just like we use #include<> in keil c51?
Can anybody tell me how to generate a time delay 0f 200microsecs using 8051
i dont think u need 2 do anything.. u can directly start with d code.. have u tried doing this?
sunny123 check out this link - http://botskool.com/forum/electronics/8051-microcontrollers/how-create-d...
Program give here is for 250ms you can easily adjust d values for 200ms
what is the widelar currunt source