<?xml version="1.0" encoding="utf-8" ?>
				<!-- generator="e107" -->
				<!-- content type="Forum / topic" -->
				<rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
				<channel rdf:about="http://www.8051projects.net/">
				<title>8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes : Forum / topic</title>
				<link>http://www.8051projects.net/</link>
				<description>Learn to make simple microcontroller projects, pic, 8051, avr and arm projects. download 8051 projects, tutorials, libraries, sample codes. join the microcontroller discussion forum and ask doubts regarding electronics. the best source for 8051 over internet.</description>
				<dc:language>en-gb</dc:language>
				<dc:date>2009-01-08T08:26:19-08:00</dc:date>
				<dc:creator>contact@nospam.com</dc:creator>
				<admin:generatorAgent rdf:resource="http://e107.org" />
				<admin:errorReportsTo rdf:resource="mailto:contact@nospam.com" />
				<sy:updatePeriod>hourly</sy:updatePeriod>
				<sy:updateFrequency>1</sy:updateFrequency>
				<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
				<items>
				<rdf:Seq>
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t2751.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t2751.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t2751.html" />
				</rdf:Seq>
				</items>
				</channel>
						<item rdf:about="http://www.8051projects.net/forum-t2751.html">
						<title>delay subroutine</title>
						<link>http://www.8051projects.net/forum-t2751.html</link>
						<dc:date>2009-01-08T08:26:19-08:00</dc:date>
						<dc:creator></dc:creator>
						<dc:subject></dc:subject>
						<description>ajay,give me the example on how to write delay assembly code by using both method,timer and register,thanks</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t2751.html">
						<title>Re: delay subroutine</title>
						<link>http://www.8051projects.net/forum-t2751.html</link>
						<dc:date>2009-01-08T08:26:19-08:00</dc:date>
						<dc:creator>Ajay</dc:creator>
						<dc:subject></dc:subject>
						<description>In timers... there are few things to take care of.. first.. amount of time you want delay for, second which timer mode is suitable for that delay.Timer increment a count every single machine cycle. so if you are using a clock of say.. 12Mhz then.. no. of times timer count is incremented is:12000000/12 = 1000000i.e. timer will be incremented 1,000,000 times in a sec.Lets say you want a delay of 10mS (0.01S)and you have to calculate the count which is to be loaded in Timer registers (THx and TLx) to find the count to be loaded.. simply multiply the required delay with the count per sec..i.e. 0.01 x 1,000,000 = 10,000so we need to count from 0 to 10,000. Maximum count for 16 bit timer is 65536. So if we load 65536-10000 = 55536 in timer registers it till automatically count 10000 times..So final value is 55536 (DF80H)so THx = DFH and TLx = 80Hthis will give you the required delay...  in case of registers.. you need to add all the time delay required for an instruction to execute and then multiply it by the loop count.. that will give you the time delay..e.g. the commonly used instructions in register delay are.. djnz Rx,label (2 machine cycles)loading value using MOV instruction also need 2 machine cycles. RET instuction and Acall instuction both need 2 machine cycles.Lets say you want a delay of 100uS then.. you are running a clock of 12Mhz, so 1 machine cycle will be of 1uS. you can divide this according to the instructions as...100 - 2(RET) - 2(lcall) - 2 (load) = 94uS left94/2 (for DJNZ) = 47 (the count)so required loop for 100uS delay is..CODE:delay100uS:<br />&nbsp; &nbsp; &nbsp; mov R7,#47<br />wait:<br />&nbsp; &nbsp; &nbsp; djnz r7,wait<br />&nbsp; &nbsp; &nbsp; ret</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t2751.html">
						<title>Re: delay subroutine</title>
						<link>http://www.8051projects.net/forum-t2751.html</link>
						<dc:date>2009-01-08T08:26:19-08:00</dc:date>
						<dc:creator>cenadius</dc:creator>
						<dc:subject></dc:subject>
						<description>ok,thanks,i need this in my exam,thanks for ur explaination</description>
						</item>
				</rdf:RDF>