<?xml version="1.0" encoding="utf-8"?>
				<!-- generator="e107" -->
				<!-- content type="Forum / topic" -->
				<rss  version="2.0">
				<channel>
				<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>

<language>en-gb</language>
				<copyright>2008 Rickey's World</copyright>
				<managingEditor>contact@nospam.com (Ajay Bhargav)</managingEditor>
				<webMaster>contact@nospam.com (Ajay Bhargav)</webMaster>
				<pubDate>Thu, 08 Jan 2009 22:36:14 -0800</pubDate>
				<lastBuildDate>Thu, 08 Jan 2009 22:36:14 -0800</lastBuildDate>
				<docs>http://backend.userland.com/rss</docs>
				<generator>e107 (http://e107.org)</generator>
				<ttl>60</ttl>
				<textInput>
				<title>Search</title>
				<description>Search 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes</description>
				<name>query</name>
				<link>http://www.8051projects.net/search.php</link>
				</textInput>
						<item>
						<title>ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[Hi everyone, I'm new in the forum. This is a good website.<br />Now, this my problem, the output of the ADC seems to give a weak output ( measured 1.1 V using multimeter). I would appreciate anyone helping  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' />  <br /><br />Problem Hints :<br />Hardware : AT89S51, ADC 0844 and 1x16 LCD<br />Case 1 : LCD displayed 00 when I include the line "<span style='color:#9933cc'>acall clr_mux_add</span>"<br />Case 2 : LCD displayed 05, 04, 00 (randomly )when I exclude the line "<span style='color:#9933cc'>acall clr_mux_add</span>"<br /><br />Port 3.0 and 3.1 are connected to separated LEDs, so I can observed the program flow, that's all.<br /><br />I programed the ADC based on the timing diagram given in the datasheet. (at the bottom of page)<br /><br />From calculation, I should get 15 or 14 decimal displayed on my LCD, but I get 05 instead, I suspected this is because it displayed the MUX Address.<br />15 decimal = 0000 1111 b (but the 1's are measured to be 1.1 V)<br /><br />Thanks for reading.  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />  <br /><br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;"><br />WR_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.5</span><br />RD_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.7</span><br />DAT_ADC <span style="color: #0000ff;">equ</span> <span style="color: #46aa03; font-weight:bold;">P2</span>&nbsp; <span style="color: #adadad; font-style: italic;">;ADC data pins P2</span><br /><br />start :<br /><span style="color: #00007f; font-weight:bold;">acall</span> clear_lcd&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> conv_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> read_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> byte_to_bcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">A</span>, <span style="color: #46aa03; font-weight:bold;">r0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_1sec&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;12</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">sjmp</span> start<br /><br />conv_adc :<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> <span style="color: #46aa03; font-weight:bold;">CS</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.1</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.0</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> mux_add <span style="color: #adadad; font-style: italic;">;set MA0-MA3 to 0101&#091;using channel 2]</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.1</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;4</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.0</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> <span style="color: #46aa03; font-weight:bold;">cs</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;5</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.1</span>&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> clr_mux_add &nbsp;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_50us<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">wait</span> : <span style="color: #00007f; font-weight:bold;">jb</span> intr_adc, <span style="color: #00007f; font-weight:bold;">wait</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;6</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.0</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">ret</span><br /><br />read_adc :<br /><span style="color: #00007f; font-weight:bold;">clr</span> <span style="color: #46aa03; font-weight:bold;">cs</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;7</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.1</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> delay_1sec&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;8</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">A</span>, DAT_ADC &nbsp;<span style="color: #adadad; font-style: italic;">;move ADC 8 bit result to A</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;mov adc_val, A</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;9</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.1</span>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">setb</span> rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;10</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">setb</span> <span style="color: #46aa03; font-weight:bold;">cs</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;11</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">ret</span><br /><br />mux_add :<br />&nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> P2<span style="color: #ff0000;">.0</span>&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;this configuration is using channel 2 single ended</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P2<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">setb</span> p2<span style="color: #ff0000;">.2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P2<span style="color: #ff0000;">.3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ret</span><br /><br />clr_mux_add :<br /><span style="color: #00007f; font-weight:bold;">clr</span> P2<span style="color: #ff0000;">.0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P2<span style="color: #ff0000;">.1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P2<span style="color: #ff0000;">.2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> P2<span style="color: #ff0000;">.3</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ret</span></div></div><br /><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1217313028_9399_FT0_timing_diagram_adc_0844.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1217313028_9399_FT0_timing_diagram_adc_0844_.jpg' class='bbcode' alt='' width='500' height='259'  /></a><br /><br /><br /><br /><img src='http://www.8051projects.net/e107_files/public/1217313232_9399_FT0_pins.jpg' class='bbcode' alt='' width='215' height='259'  />]]></description>
<pubDate>Mon, 28 Jul 2008 23:37:08 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[try using interrupt..<br />you are wasting more time on making LEDs low high <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' /> <br />so interrupt will solve your problem <img src='http://www.8051projects.net/e107_images/emotes/yahoo/3.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 29 Jul 2008 08:17:03 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[aaa, thanks for idea.... is there any other way ?  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/22.gif' alt='' style='vertical-align:middle; border:0' />  <br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 29 Jul 2008 10:07:17 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[<strong class='bbcode bold'>Hi again, i've found the solution ( i think so) <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />  , all i did is add the highlighted line (compare with code above).<br /></strong><br /><br /><img src='http://www.8051projects.net/e107_files/public/1217359032_9399_FT11195_line.jpg' class='bbcode' alt='' width='491' height='156'  /><br /><br /><strong class='bbcode bold'>all thx to :  <a class='bbcode' href='http://www.8051projects.net/downloads84.html' rel='external'  target='_blank'>http://www.8051projects.net/downloads84.html</a> </strong><br /><br /><strong class='bbcode bold'>because on page 59, i found this :</strong><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1217359234_9399_FT11195_note.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1217359234_9399_FT11195_note_.jpg' class='bbcode' alt='' width='500' height='88'  /></a><br /><br /><br /><strong class='bbcode bold'>if it wasn't for Ajay, i wouldn't go hay-wire finding info about interrupts... hahaha  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/22.gif' alt='' style='vertical-align:middle; border:0' />  , so thx Ajay.<br />now, the temperature displayed a more "make sense" value. Now i only use 0.5 sec of temperature sampling.</strong><br /><br /><span style='color:#ff0000'><strong class='bbcode bold'>New problem : <br />The temperature reading is not so stable. It changes to different value too rapidly.  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/17.gif' alt='' style='vertical-align:middle; border:0' />  <br />So, any engineering ideas are seriously welcomed !!  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' />  </strong></span>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 29 Jul 2008 12:32:18 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[<br /><br />  hi freddy,<br /><br /><div class='indent'>acall clear_lcd</div><br /><br />why are you clearing the LCD every time in start loop ?  if you are using two channels then  one channel reading can be placed on line 1 and  other channel data on line 2 of lcd.<br /><br />if you are using only one ch, then you need not clear the LCD every time.<br /><br /><br /><br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 29 Jul 2008 18:54:01 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[<strong class='bbcode bold'>I only use 1 channel of the ADC.<br />When i remove the acall clear_lcd , the display would be continuous.<br />Something like this : 100F0F10<br /></strong><br /><br /> <img src='http://www.8051projects.net/e107_images/emotes/yahoo/22.gif' alt='' style='vertical-align:middle; border:0' />  <br /><br /><strong class='bbcode bold'>or maybe i understood u wrongly ??  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/22.gif' alt='' style='vertical-align:middle; border:0' />  </strong>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 29 Jul 2008 21:52:27 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[<br /><br /> Hi Freddy,<br /><br />you have posted only part of the code, pl.post full code so that we can analyze other subroutines and find the error.<br /><br />since you are using 1 ch and not switching between channels, it is not required to clear the LCD after every cycle.<br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 29 Jul 2008 23:56:37 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[owh okok, sorry about that. I'm just a beginner.   <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />  <br /><br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;"><br /><span style="color: #adadad; font-style: italic;">;Information :</span><br /><span style="color: #adadad; font-style: italic;">;the code is initilaise as 2x16 although it is 1x16 </span><br /><span style="color: #adadad; font-style: italic;">;because of the 8+8 configuration.</span><br /><span style="color: #adadad; font-style: italic;">;the ninth position start at the address 40h</span><br /><span style="color: #adadad; font-style: italic;">;&#091;00 01 02 03 04 05 06 07 41 42 43 44 45 46 47]</span><br /><span style="color: #adadad; font-style: italic;">;#07h --&gt; shift display to the left</span><br /><span style="color: #0000ff;">ORG</span> <span style="color: #ff0000;">0000H</span><br /><br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">P0</span>, #<span style="color: #ff0000;">00h</span><br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">P1</span>, #<span style="color: #ff0000;">00h</span><br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">P2</span>, #<span style="color: #ff0000;">00h</span><br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">P3</span>, #<span style="color: #ff0000;">00h</span><br /><br /><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TMOD</span>, #0x01<br /><br />RS_lcd <span style="color: #0000ff;">EQU</span> P1<span style="color: #ff0000;">.2</span><br />RW_lcd <span style="color: #0000ff;">EQU</span> P1<span style="color: #ff0000;">.1</span><br />EN_lcd <span style="color: #0000ff;">EQU</span> P1<span style="color: #ff0000;">.0</span><br />DAT_lcd <span style="color: #0000ff;">EQU</span> <span style="color: #46aa03; font-weight:bold;">P0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;LCD PORT for DB0 to DB7</span><br /><br />INTR_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.4</span><br />WR_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.5</span><br />CS_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.6</span><br />RD_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.7</span><br />DAT_ADC <span style="color: #0000ff;">equ</span> <span style="color: #46aa03; font-weight:bold;">P2</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;ADC data pins P2</span><br />mux_add <span style="color: #0000ff;">equ</span> 30h<br /><br /><span style="color: #00007f; font-weight:bold;">aCALL</span> INIT_LCD<br /><br /><span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.5</span><br /><span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.6</span><br /><span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.7</span><br /><span style="color: #00007f; font-weight:bold;">mov</span> mux_add, #<span style="color: #ff0000;">00000101b</span> <span style="color: #adadad; font-style: italic;">;channel 2, single-ended mode</span><br /><span style="color: #adadad; font-style: italic;">;==============================================================</span><br />disp_str <span style="color: #0000ff;">macro</span> string&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;Macro for sending string to LCD</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">irpc</span> char, &lt;string&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">if</span> nul <span style="color: #7f007f;">'char'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">exitm</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">endif</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">a</span>,#<span style="color: #7f007f;">'char'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">lcall</span> write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">endm</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">endm</span><br /><br />start :<br /><span style="color: #00007f; font-weight:bold;">acall</span> clear_lcd<br /><span style="color: #00007f; font-weight:bold;">acall</span> conv_adc<br />disp_str &lt;Temp:&gt;<br /><span style="color: #00007f; font-weight:bold;">mov</span> dat_lcd, #85h &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;80h + 05h (instruction + lcd mapping address)</span><br /><span style="color: #00007f; font-weight:bold;">setb</span> en_lcd<br /><span style="color: #00007f; font-weight:bold;">acall</span> delay_2ms<br /><span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br /><br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">P2</span>, 0xFF &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;configure to read from port 2</span><br /><span style="color: #00007f; font-weight:bold;">acall</span> read_adc<br /><span style="color: #00007f; font-weight:bold;">acall</span> byte_to_bcd&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">acall</span> write_text &nbsp; <span style="color: #adadad; font-style: italic;">;display upper nibble</span><br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">A</span>, <span style="color: #46aa03; font-weight:bold;">r0</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;display lower nibble</span><br /><span style="color: #00007f; font-weight:bold;">acall</span> write_text<br /><span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">sjmp</span> start<br /><br />conv_adc :<br /><span style="color: #00007f; font-weight:bold;">clr</span> wr_adc<br /><span style="color: #00007f; font-weight:bold;">nop</span><br /><span style="color: #00007f; font-weight:bold;">mov</span> dat_adc, mux_add <span style="color: #adadad; font-style: italic;">;load mux address into A</span><br /><span style="color: #00007f; font-weight:bold;">nop</span><br /><span style="color: #00007f; font-weight:bold;">setb</span> wr_adc<br /><span style="color: #00007f; font-weight:bold;">wait</span> : <span style="color: #00007f; font-weight:bold;">jb</span> intr_adc, <span style="color: #00007f; font-weight:bold;">wait</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">ret</span><br /><br />read_adc :<br /><span style="color: #00007f; font-weight:bold;">clr</span> rd_adc<br /><span style="color: #00007f; font-weight:bold;">nop</span><br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">A</span>, DAT_ADC &nbsp;<span style="color: #adadad; font-style: italic;">;move ADC 8 bit result to A</span><br /><span style="color: #00007f; font-weight:bold;">nop</span><br /><span style="color: #00007f; font-weight:bold;">setb</span> rd_adc<br /><span style="color: #00007f; font-weight:bold;">nop</span><br /><span style="color: #00007f; font-weight:bold;">ret</span><br /><span style="color: #adadad; font-style: italic;">;==========================================================</span><br /><span style="color: #adadad; font-style: italic;">;this subroutine converts 8-bit data to bcd</span><br /><span style="color: #adadad; font-style: italic;">;both high nibble and low nibble are in hex value</span><br /><span style="color: #adadad; font-style: italic;">;input is taken from A</span><br /><span style="color: #adadad; font-style: italic;">;the output high nibble is A (hex value)</span><br /><span style="color: #adadad; font-style: italic;">;the output low nibble is in r0 (also hex value)</span><br />byte_to_bcd:<br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">R0</span>,<span style="color: #46aa03; font-weight:bold;">A</span><br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ANL</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#<span style="color: #ff0000;">0Fh</span><br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ADD</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#<span style="color: #ff0000;">0F6h</span><br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">JNC</span> &nbsp; &nbsp; byte_to_bcd_2<br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ADD</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#<span style="color: #ff0000;">07h</span><br />byte_to_bcd_2:<br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ADD</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#3Ah<br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">XCH</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,<span style="color: #46aa03; font-weight:bold;">R0</span><br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SWAP</span> &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">A</span><br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ANL</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#<span style="color: #ff0000;">0Fh</span><br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ADD</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#<span style="color: #ff0000;">0F6h</span><br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">JNC</span> &nbsp; &nbsp; byte_to_bcd_3<br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ADD</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#<span style="color: #ff0000;">07h</span><br />byte_to_bcd_3:<br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">ADD</span> &nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">A</span>,#3Ah<br />&nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span>&nbsp;<br /><span style="color: #adadad; font-style: italic;">;===========================================================</span><br />WAIT_LCD : &nbsp;<br /><span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">RET</span><br /><br />INIT_LCD : &nbsp;<br /><span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br /><span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br /><span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br /><span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd, #38h &nbsp;<span style="color: #adadad; font-style: italic;">;initialize lcd as 2x16&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br /><span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br /><span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><br /><span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br /><span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br /><span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br /><span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#<span style="color: #ff0000;">0Ch</span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;no cursor, no blinking of cursor&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br /><span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br /><span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><br /><span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br /><span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br /><span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br /><span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#<span style="color: #ff0000;">06h</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br /><span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><br /><span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br /><span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br /><span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br /><span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#14h<br /><span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br /><span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><span style="color: #00007f; font-weight:bold;">RET</span><br /><br />CLEAR_LCD :&nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br /><span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br /><span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br /><span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#<span style="color: #ff0000;">01h</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br /><span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><span style="color: #00007f; font-weight:bold;">RET</span><br /><br />WRITE_TEXT :<br /><span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br /><span style="color: #00007f; font-weight:bold;">SETB</span> RS_lcd<br /><span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd, <span style="color: #46aa03; font-weight:bold;">A</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br />&nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br /><span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br /><span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><span style="color: #00007f; font-weight:bold;">RET</span><br /><span style="color: #adadad; font-style: italic;">;===========================================================================</span><br /><span style="color: #adadad; font-style: italic;">;Delay subroutines...</span><br />DELAY_50us: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">1</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 50 micro second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp;</span><br />REPEAT_4:<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xD2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_4:&nbsp;<span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, REPEAT_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />DELAY_33ms: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">100</span> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 33 mili second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp; </span><br />REPEAT_3:<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xFE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xCF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_3:&nbsp; NB TF0, BACK_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, REPEAT_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />DELAY_2ms: &nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">100</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 2ms delay subroutine&nbsp; &nbsp;</span><br /><span style="color: #0000ff;">REPEAT</span>:&nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK:&nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, <span style="color: #0000ff;">REPEAT</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />DELAY_500ms: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">r5</span>, #<span style="color: #ff0000;">100</span>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 0.5 second delay subroutine&nbsp; &nbsp; </span><br />REPEAT_2:<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0x00<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_2:&nbsp;<span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">r5</span>, REPEAT_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />DELAY_1sec: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">100</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 1 second delay subroutine&nbsp; &nbsp; &nbsp; </span><br />REPEAT_1:<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xD8<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_1:&nbsp;<span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, REPEAT_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #0000ff;">END</span><br />&nbsp;</div></div>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 30 Jul 2008 03:09:31 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[Hi Freddy,<br /><br /> first things first :<br /><br /><div class='indent'>mov P0, #00h<br />mov P1, #00h<br />mov P2, #00h<br />mov P3, #00h</div><br /><br />this is a big No-No, on reset all the ports are 0FFh by default so lets keep it that way.<br /><br />in subroutine  byte_to_bcd:<br /><br /><div class='indent'>ADD     A,#3Ah</div> <br /><br />it should be #30H ( since you are converting into Ascii for sending it to LCD), also i doubt if this routine is right, bcoz to display FFh you need 3 digits in BCD i,e 255 but you are displaying only 2 digits ( A &amp; R0)<br /><br />you can use the following routine, which converts 1 byte Hex to 3 digit decimal ( you need to declare the variables - hundreds, tens &amp; ones):<br /><br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;">Bin2Dec:<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">b</span>,#100d<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">div</span> ab<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> hundreds,<span style="color: #46aa03; font-weight:bold;">a</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">a</span>,<span style="color: #46aa03; font-weight:bold;">b</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">b</span>,#10d<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">div</span> ab<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> tens,<span style="color: #46aa03; font-weight:bold;">a</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> ones,<span style="color: #46aa03; font-weight:bold;">b</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">ret</span> &nbsp; &nbsp; &nbsp;</div></div><br /><br />and when dispatching to LCD, just add or ORL #30h to hunds, tens &amp; ones <img src='http://www.8051projects.net/e107_images/emotes/yahoo/3.gif' alt='' style='vertical-align:middle; border:0' /> <br /><br /><br />in the DELAY_1sec rountine,<br />                <div class='indent'>MOV TH0, #0xD8<br />                MOV TL0, #0xF0</div><br /><br />the timer reload values are wrong, you haven't mentioned the xtal Freq  but i guess you are using 11.0592Mhz<br /><br />it should be : <div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;"><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>,#<span style="color: #ff0000;">0DCH</span> &nbsp;<span style="color: #adadad; font-style: italic;">; &nbsp;10mSec X 100(R5) &nbsp;= 1000mS</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>,#<span style="color: #ff0000;">00H</span></div></div><br /><br />make these changes and check if the LCD displays correctly  <br /><br />PS: i hope the interfacing sequence to the ADC is correct ( write/read ).<br /><br />All  the Best !<br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 30 Jul 2008 07:30:42 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[<strong class='bbcode bold'>wow Arun, now I can display the results in decimal value instead of hex. Thanks  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' />  <br />I recalculate the formula, I still think that my 1 second delay is correct. I'm using 11.0592 MHz<br /><br />100 x (65536-55536) x 1.085 us = 1.085 sec  ( approx. 1 sec)<br />   (1/11.0592 Mhz) / 12 = 921,600 Hz<br />   1 / 921,600 = 1.085 us<br />   D8F0h = 55536 <br /><br /><span style='color:#cc00cc'>Now, my problem is :<br />The temperature reading is fluctuating from 14-18 at room temperature ( i set Vref of ADC to Vcc=4.9 V). From calculation, I should get 15 or 16. <br /><br />I suspected this is because of I didn't have any signal conditioning circuit for the ADC analog input. Can this be the problem ??</span> </strong><br /><br /><img src='http://www.8051projects.net/e107_files/public/1217481026_9399_FT11195_picture1.jpg' class='bbcode' alt='' width='237' height='98'  /><br /><br /><strong class='bbcode bold'>Vin is from LM35 temp sensor = 0.29 V<br />stepsize for ADC = 4.90 V / 256 = 19 mV<br />Dout is in decimal<br />0.29 / 19mV = 15.263<br /></strong> <span style='color:#cc0099'></span> <br /><br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;"><br /><span style="color: #adadad; font-style: italic;">;Information :</span><br /><span style="color: #adadad; font-style: italic;">;the code is initilaise as 2x16 although it is 1x16 </span><br /><span style="color: #adadad; font-style: italic;">;because of the 8+8 configuration.</span><br /><span style="color: #adadad; font-style: italic;">;the ninth position start at the address 40h</span><br /><span style="color: #adadad; font-style: italic;">;&#091;00 01 02 03 04 05 06 07 41 42 43 44 45 46 47]</span><br /><span style="color: #adadad; font-style: italic;">;#07h --&gt; shift display to the left</span><br /><span style="color: #0000ff;">ORG</span> <span style="color: #ff0000;">0000H</span><br /><br /><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TMOD</span>, #0x01<br /><br />RS_lcd <span style="color: #0000ff;">EQU</span> P1<span style="color: #ff0000;">.2</span><br />RW_lcd <span style="color: #0000ff;">EQU</span> P1<span style="color: #ff0000;">.1</span><br />EN_lcd <span style="color: #0000ff;">EQU</span> P1<span style="color: #ff0000;">.0</span><br />DAT_lcd <span style="color: #0000ff;">EQU</span> <span style="color: #46aa03; font-weight:bold;">P0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;LCD PORT for DB0 to DB7</span><br /><br />INTR_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.4</span><br />WR_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.5</span><br />CS_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.6</span><br />RD_adc <span style="color: #0000ff;">equ</span> P3<span style="color: #ff0000;">.7</span><br />DAT_ADC <span style="color: #0000ff;">equ</span> <span style="color: #46aa03; font-weight:bold;">P2</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;ADC data pins P2</span><br />mux_add <span style="color: #0000ff;">equ</span> 30h<br />hundreds <span style="color: #0000ff;">equ</span> 31h<br />tens <span style="color: #0000ff;">equ</span> 32h<br />ones <span style="color: #0000ff;">equ</span> 33h<br /><br /><span style="color: #00007f; font-weight:bold;">aCALL</span> INIT_LCD<br /><br /><span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.5</span> &nbsp;<span style="color: #adadad; font-style: italic;">;initialize wr_adc high</span><br /><span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.6</span> &nbsp; <span style="color: #adadad; font-style: italic;">;set cs_adc always low</span><br /><span style="color: #00007f; font-weight:bold;">setb</span> P3<span style="color: #ff0000;">.7</span> &nbsp;<span style="color: #adadad; font-style: italic;">;initialize rd_adc high</span><br /><br /><span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.0</span> <span style="color: #adadad; font-style: italic;">;off LED connected to P3.0</span><br /><span style="color: #00007f; font-weight:bold;">clr</span> P3<span style="color: #ff0000;">.1</span> &nbsp;<span style="color: #adadad; font-style: italic;">;off LED connected to P3.1</span><br /><br /><span style="color: #00007f; font-weight:bold;">mov</span> mux_add, #<span style="color: #ff0000;">00000101b</span> <span style="color: #adadad; font-style: italic;">;MUX address for ADC0844</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;channel 2, single-ended mode</span><br /><span style="color: #adadad; font-style: italic;">;==============================================================</span><br />disp_str <span style="color: #0000ff;">macro</span> string&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;Macro for sending string to LCD</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">irpc</span> char, &lt;string&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">if</span> nul <span style="color: #7f007f;">'char'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">exitm</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">endif</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">a</span>,#<span style="color: #7f007f;">'char'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">lcall</span> write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">endm</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">endm</span><br /><br />start : <span style="color: #00007f; font-weight:bold;">acall</span> clear_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> conv_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; disp_str &lt;Temp:&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">P2</span>, 0xFF &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;configure to read from port 2</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> read_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> bin2dec<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> ascii4lcd_tens&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> write_text &nbsp; <span style="color: #adadad; font-style: italic;">;write tens to LCD</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> ascii4lcd_ones&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> write_text &nbsp; <span style="color: #adadad; font-style: italic;">;write ones to LCD</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rs_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">mov</span> dat_lcd, #<span style="color: #ff0000;">0C0h</span> <span style="color: #adadad; font-style: italic;">;80h + 40h (instruction + lcd mapping address)</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">setb</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> delay_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> wait_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; disp_str &lt;Celcius&gt;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">sjmp</span> start<br /><span style="color: #adadad; font-style: italic;">;====================================================</span><br />Bin2Dec:<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">b</span>,#100d <span style="color: #adadad; font-style: italic;">;1100 0100</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">div</span> ab<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> hundreds,<span style="color: #46aa03; font-weight:bold;">a</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">a</span>,<span style="color: #46aa03; font-weight:bold;">b</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">b</span>,#10d<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">div</span> ab<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> tens,<span style="color: #46aa03; font-weight:bold;">a</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> ones,<span style="color: #46aa03; font-weight:bold;">b</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">ret</span><br /><span style="color: #adadad; font-style: italic;">;=============================================</span><br />ascii4lcd_tens :<br /><span style="color: #00007f; font-weight:bold;">add</span> <span style="color: #46aa03; font-weight:bold;">A</span>, #30h&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;add 30h to tens value</span><br /><span style="color: #00007f; font-weight:bold;">ret</span><br /><br />ascii4lcd_ones :<br /><span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">A</span>, <span style="color: #46aa03; font-weight:bold;">B</span><br /><span style="color: #00007f; font-weight:bold;">add</span> <span style="color: #46aa03; font-weight:bold;">A</span>, #30h<br /><span style="color: #00007f; font-weight:bold;">ret</span><br /><span style="color: #adadad; font-style: italic;">;=========================================================</span><br />conv_adc :<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">mov</span> dat_adc, mux_add <span style="color: #adadad; font-style: italic;">;load mux address into A</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">wait</span> : <span style="color: #00007f; font-weight:bold;">jb</span> intr_adc, <span style="color: #00007f; font-weight:bold;">wait</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">ret</span><br /><br />read_adc : <span style="color: #00007f; font-weight:bold;">clr</span> rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">nop</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">mov</span> <span style="color: #46aa03; font-weight:bold;">A</span>, DAT_ADC &nbsp;<span style="color: #adadad; font-style: italic;">;move ADC 8 bit result to A</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">setb</span> rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">nop</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">ret</span><br /><span style="color: #adadad; font-style: italic;">;==========================================================</span><br /><span style="color: #adadad; font-style: italic;">;===========================================================</span><br />WAIT_LCD : &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">RET</span><br /><br />INIT_LCD : &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd, #38h &nbsp;<span style="color: #adadad; font-style: italic;">;initialize lcd as 2x16&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#<span style="color: #ff0000;">0Ch</span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;no cursor, no blinking of cursor&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#<span style="color: #ff0000;">06h</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#14h<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />CLEAR_LCD :&nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd,#<span style="color: #ff0000;">01h</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />WRITE_TEXT : <span style="color: #00007f; font-weight:bold;">clr</span> en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">SETB</span> RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">clr</span> rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> DAT_lcd, <span style="color: #46aa03; font-weight:bold;">A</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">SETB</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">acall</span> DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">CLR</span> EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">aCALL</span> WAIT_LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">RET</span><br /><span style="color: #adadad; font-style: italic;">;===========================================================================</span><br /><span style="color: #adadad; font-style: italic;">;Delay subroutines...</span><br />DELAY_50us: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">1</span> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 50 micro second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp;</span><br />REPEAT_4:&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xD2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_4:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, REPEAT_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />DELAY_33ms: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">100</span> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 33 mili second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp; </span><br />REPEAT_3:&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xFE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xCF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_3:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, REPEAT_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />DELAY_2ms: &nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">100</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 2ms delay subroutine&nbsp; &nbsp;</span><br /><span style="color: #0000ff;">REPEAT</span>:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK:&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, <span style="color: #0000ff;">REPEAT</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br /><br />DELAY_500ms: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">r5</span>, #<span style="color: #ff0000;">100</span>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 0.5 second delay subroutine&nbsp; &nbsp; </span><br />REPEAT_2:&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0x00<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_2:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">r5</span>, REPEAT_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />DELAY_1sec: <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, #<span style="color: #ff0000;">100</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;this is a 1 second delay subroutine&nbsp; &nbsp; &nbsp; </span><br />REPEAT_1:&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TH0</span>, #0xD8<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TL0</span>, #0xF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br />BACK_1:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">JNB</span> TF0, BACK_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CLR</span> TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R5</span>, REPEAT_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">RET</span>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #0000ff;">END</span><br />&nbsp;</div></div>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 30 Jul 2008 22:20:58 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[Hi Freddy,<br /><br /><div class='indent'>I recalculate the formula, I still think that my 1 second delay is correct. I'm using 11.0592 MHz</div><br /><br />your calculation is based on 12Mhz crystal freq, my guess proved correct that you are using 11.0592Meg xtal.<br /><br />so here is the calculation  for 10mSec delay using 11.0592 meg ( 10mS X 100 times =1sec):<br /><br />1) 10,000 divided by 1.085uS = 9216 decimal<br />2) 65536 - 9216 = 56,320 decimal<br />3) 56,320 d = 0DC00h<br />4) TH0 = 0DCh , TL0 = 00h<br /><br />you can cross check by multiplying 9216 X 1.085 = 9999.36 uSec <br /><br />but your values give a delay  of 10,000 X 1.085 = 10,850 uSec a delay <br /><br /><br />about the variation in reading, i'll find let you where the error is<br /><br /><br /><br />Arun<br /><br /><br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Thu, 31 Jul 2008 03:14:42 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
						<item>
						<title>Re: ADC 0844 errorneous results. Help me.</title>
<link>http://www.8051projects.net/forum-t11195.html</link>
<description><![CDATA[<span style='color:#3333ff'><strong class='bbcode bold'>Yup, got it now. Thank you so much Arun  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' />  <br />I think I'll switch to 12 MHz </strong> </span>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 01 Aug 2008 10:05:57 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t11195.html</guid>
</item>
				</channel>
				</rss>