<?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:54:51-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-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t11195.html" />
				</rdf:Seq>
				</items>
				</channel>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator></dc:creator>
						<dc:subject></dc:subject>
						<description>Hi everyone, I'm new in the forum. This is a good website.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    Problem Hints :Hardware : AT89S51, ADC 0844 and 1x16 LCDCase 1 : LCD displayed 00 when I include the line "acall clr_mux_add"Case 2 : LCD displayed 05, 04, 00 (randomly )when I exclude the line "acall clr_mux_add"Port 3.0 and 3.1 are connected to separated LEDs, so I can observed the program flow, that's all.I programed the ADC based on the timing diagram given in the datasheet. (at the bottom of page)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.15 decimal = 0000 1111 b (but the 1's are measured to be 1.1 V)Thanks for reading.    CODE:<br />WR_adc equ P3.5<br />RD_adc equ P3.7<br />DAT_ADC equ P2&nbsp; ;ADC data pins P2<br /><br />start :<br />acall 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; acall conv_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall read_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall 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; acall write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov A, r0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setb P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_1sec&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;12<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P3.0&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; sjmp start<br /><br />conv_adc :<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr CS<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_500ms&nbsp; &nbsp; &nbsp; ;1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.1<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_500ms&nbsp; &nbsp; &nbsp;;2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.0<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall mux_add ;set MA0-MA3 to 0101&#091;using channel 2]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_500ms&nbsp; &nbsp; &nbsp; ;3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.1<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_500ms&nbsp; &nbsp; &nbsp; ;4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.0<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb cs<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;;5<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.1&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall clr_mux_add &nbsp;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_50us<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wait : jb intr_adc, wait<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;6<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.0<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ret<br /><br />read_adc :<br />clr cs<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;;7<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P3.1<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; clr rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; acall delay_1sec&nbsp; &nbsp; &nbsp; &nbsp; ;8<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; mov A, DAT_ADC &nbsp;;move ADC 8 bit result to A<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;mov adc_val, A<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;;9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.1&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setb rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;;10<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr P3.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setb cs<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb P3.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;;11<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P3.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ret<br /><br />mux_add :<br />&nbsp;setb P2.0&nbsp; &nbsp; &nbsp; &nbsp;;this configuration is using channel 2 single ended<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P2.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setb p2.2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P2.3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ret<br /><br />clr_mux_add :<br />clr P2.0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P2.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P2.2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr P2.3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ret</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Ajay</dc:creator>
						<dc:subject></dc:subject>
						<description>try using interrupt..you are wasting more time on making LEDs low high  so interrupt will solve your problem</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Freddy</dc:creator>
						<dc:subject></dc:subject>
						<description>aaa, thanks for idea.... is there any other way ?</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Freddy</dc:creator>
						<dc:subject></dc:subject>
						<description>Hi again, i've found the solution ( i think so)   , all i did is add the highlighted line (compare with code above).all thx to :  http://www.8051projects.net/downloads84.html because on page 59, i found this :if it wasn't for Ajay, i wouldn't go hay-wire finding info about interrupts... hahaha    , so thx Ajay.now, the temperature displayed a more "make sense" value. Now i only use 0.5 sec of temperature sampling.New problem : The temperature reading is not so stable. It changes to different value too rapidly.    So, any engineering ideas are seriously welcomed !!</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Arun Kumar V</dc:creator>
						<dc:subject></dc:subject>
						<description>hi freddy,acall clear_lcdwhy 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.if you are using only one ch, then you need not clear the LCD every time.Arun</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Freddy</dc:creator>
						<dc:subject></dc:subject>
						<description>I only use 1 channel of the ADC.When i remove the acall clear_lcd , the display would be continuous.Something like this : 100F0F10   or maybe i understood u wrongly ??</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Arun Kumar V</dc:creator>
						<dc:subject></dc:subject>
						<description>Hi Freddy,you have posted only part of the code, pl.post full code so that we can analyze other subroutines and find the error.since you are using 1 ch and not switching between channels, it is not required to clear the LCD after every cycle.Arun</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Freddy</dc:creator>
						<dc:subject></dc:subject>
						<description>owh okok, sorry about that. I'm just a beginner.     CODE:<br />;Information :<br />;the code is initilaise as 2x16 although it is 1x16 <br />;because of the 8+8 configuration.<br />;the ninth position start at the address 40h<br />;&#091;00 01 02 03 04 05 06 07 41 42 43 44 45 46 47]<br />;#07h --> shift display to the left<br />ORG 0000H<br /><br />mov P0, #00h<br />mov P1, #00h<br />mov P2, #00h<br />mov P3, #00h<br /><br />MOV TMOD, #0x01<br /><br />RS_lcd EQU P1.2<br />RW_lcd EQU P1.1<br />EN_lcd EQU P1.0<br />DAT_lcd EQU P0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;LCD PORT for DB0 to DB7<br /><br />INTR_adc equ P3.4<br />WR_adc equ P3.5<br />CS_adc equ P3.6<br />RD_adc equ P3.7<br />DAT_ADC equ P2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;ADC data pins P2<br />mux_add equ 30h<br /><br />aCALL INIT_LCD<br /><br />setb P3.5<br />clr P3.6<br />setb P3.7<br />mov mux_add, #00000101b ;channel 2, single-ended mode<br />;==============================================================<br />disp_str macro string&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;Macro for sending string to LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;irpc char, &lt;string><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if nul 'char'<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exitm<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;endif<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mov a,#'char'<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lcall write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;endm<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;endm<br /><br />start :<br />acall clear_lcd<br />acall conv_adc<br />disp_str &lt;Temp:><br />mov dat_lcd, #85h &nbsp; &nbsp; &nbsp; ;80h + 05h (instruction + lcd mapping address)<br />setb en_lcd<br />acall delay_2ms<br />clr en_lcd<br /><br />mov P2, 0xFF &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;configure to read from port 2<br />acall read_adc<br />acall byte_to_bcd&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br />acall write_text &nbsp; ;display upper nibble<br />mov A, r0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;display lower nibble<br />acall write_text<br />acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<br />sjmp start<br /><br />conv_adc :<br />clr wr_adc<br />nop<br />mov dat_adc, mux_add ;load mux address into A<br />nop<br />setb wr_adc<br />wait : jb intr_adc, wait&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />ret<br /><br />read_adc :<br />clr rd_adc<br />nop<br />mov A, DAT_ADC &nbsp;;move ADC 8 bit result to A<br />nop<br />setb rd_adc<br />nop<br />ret<br />;==========================================================<br />;this subroutine converts 8-bit data to bcd<br />;both high nibble and low nibble are in hex value<br />;input is taken from A<br />;the output high nibble is A (hex value)<br />;the output low nibble is in r0 (also hex value)<br />byte_to_bcd:<br />&nbsp; &nbsp; MOV &nbsp; &nbsp; R0,A<br />&nbsp; &nbsp; ANL &nbsp; &nbsp; A,#0Fh<br />&nbsp; &nbsp; ADD &nbsp; &nbsp; A,#0F6h<br />&nbsp; &nbsp; JNC &nbsp; &nbsp; byte_to_bcd_2<br />&nbsp; &nbsp; ADD &nbsp; &nbsp; A,#07h<br />byte_to_bcd_2:<br />&nbsp; &nbsp; ADD &nbsp; &nbsp; A,#3Ah<br />&nbsp; &nbsp; XCH &nbsp; &nbsp; A,R0<br />&nbsp; &nbsp; SWAP &nbsp; &nbsp;A<br />&nbsp; &nbsp; ANL &nbsp; &nbsp; A,#0Fh<br />&nbsp; &nbsp; ADD &nbsp; &nbsp; A,#0F6h<br />&nbsp; &nbsp; JNC &nbsp; &nbsp; byte_to_bcd_3<br />&nbsp; &nbsp; ADD &nbsp; &nbsp; A,#07h<br />byte_to_bcd_3:<br />&nbsp; &nbsp; ADD &nbsp; &nbsp; A,#3Ah<br />&nbsp; &nbsp; RET&nbsp;<br />;===========================================================<br />WAIT_LCD : &nbsp;<br />acall DELAY_2ms &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br />RET<br /><br />INIT_LCD : &nbsp;<br />clr en_lcd<br />CLR RS_lcd<br />clr rw_lcd<br />MOV DAT_lcd, #38h &nbsp;;initialize lcd as 2x16&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />SETB EN_lcd<br />acall DELAY_2ms<br />CLR EN_lcd<br />aCALL WAIT_LCD<br /><br />clr en_lcd<br />CLR RS_lcd<br />clr rw_lcd<br />MOV DAT_lcd,#0Ch&nbsp; &nbsp; &nbsp; &nbsp; ;no cursor, no blinking of cursor&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />SETB EN_lcd<br />acall DELAY_2ms<br />CLR EN_lcd<br />aCALL WAIT_LCD<br /><br />clr en_lcd<br />CLR RS_lcd<br />clr rw_lcd<br />MOV DAT_lcd,#06h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />SETB EN_lcd<br />acall DELAY_2ms<br />CLR EN_lcd<br />aCALL WAIT_LCD<br /><br />clr en_lcd<br />CLR RS_lcd<br />clr rw_lcd<br />MOV DAT_lcd,#14h<br />SETB EN_lcd<br />acall DELAY_2ms<br />CLR EN_lcd<br />aCALL WAIT_LCD<br />RET<br /><br />CLEAR_LCD :&nbsp; &nbsp; &nbsp;<br />clr en_lcd<br />CLR RS_lcd<br />clr rw_lcd<br />MOV DAT_lcd,#01h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />SETB EN_lcd<br />acall DELAY_2ms<br />CLR EN_lcd<br />aCALL WAIT_LCD<br />RET<br /><br />WRITE_TEXT :<br />clr en_lcd<br />SETB RS_lcd<br />clr rw_lcd<br />&nbsp;MOV DAT_lcd, A&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />SETB EN_lcd<br />&nbsp;acall DELAY_2ms<br />CLR EN_lcd<br />aCALL WAIT_LCD<br />RET<br />;===========================================================================<br />;Delay subroutines...<br />DELAY_50us: MOV R5, #1 &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;this is a 50 micro second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp;<br />REPEAT_4:MOV TH0, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xD2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_4:&nbsp;JNB TF0, BACK_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />DELAY_33ms: MOV R5, #100 &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;this is a 33 mili second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp; <br />REPEAT_3:MOV TH0, #0xFE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xCF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_3:&nbsp; NB TF0, BACK_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />DELAY_2ms: &nbsp;MOV R5, #100&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;this is a 2ms delay subroutine&nbsp; &nbsp;<br />REPEAT:&nbsp;MOV TH0, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK:&nbsp; &nbsp;JNB TF0, BACK<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />DELAY_500ms: MOV r5, #100&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;this is a 0.5 second delay subroutine&nbsp; &nbsp; <br />REPEAT_2:MOV TH0, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0x00<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_2:&nbsp;JNB TF0, BACK_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ r5, REPEAT_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />DELAY_1sec: MOV R5, #100&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;this is a 1 second delay subroutine&nbsp; &nbsp; &nbsp; <br />REPEAT_1:MOV TH0, #0xD8<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_1:&nbsp;JNB TF0, BACK_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET&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 />END<br />&nbsp;</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Arun Kumar V</dc:creator>
						<dc:subject></dc:subject>
						<description>Hi Freddy, first things first :mov P0, #00hmov P1, #00hmov P2, #00hmov P3, #00hthis is a big No-No, on reset all the ports are 0FFh by default so lets keep it that way.in subroutine  byte_to_bcd:ADD     A,#3Ah 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)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):CODE:Bin2Dec:<br />&nbsp; &nbsp; &nbsp; &nbsp;mov b,#100d<br />&nbsp; &nbsp; &nbsp; &nbsp;div ab<br />&nbsp; &nbsp; &nbsp; &nbsp;mov hundreds,a<br />&nbsp; &nbsp; &nbsp; &nbsp;mov a,b<br />&nbsp; &nbsp; &nbsp; &nbsp;mov b,#10d<br />&nbsp; &nbsp; &nbsp; &nbsp;div ab<br />&nbsp; &nbsp; &nbsp; &nbsp;mov tens,a<br />&nbsp; &nbsp; &nbsp; &nbsp;mov ones,b<br />&nbsp; &nbsp; &nbsp; &nbsp;ret &nbsp; &nbsp; &nbsp;and when dispatching to LCD, just add or ORL #30h to hunds, tens &amp; ones  in the DELAY_1sec rountine,                MOV TH0, #0xD8                MOV TL0, #0xF0the timer reload values are wrong, you haven't mentioned the xtal Freq  but i guess you are using 11.0592Mhzit should be : CODE:MOV TH0,#0DCH &nbsp;; &nbsp;10mSec X 100(R5) &nbsp;= 1000mS<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0,#00Hmake these changes and check if the LCD displays correctly  PS: i hope the interfacing sequence to the ADC is correct ( write/read ).All  the Best !Arun</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Freddy</dc:creator>
						<dc:subject></dc:subject>
						<description>wow Arun, now I can display the results in decimal value instead of hex. Thanks    I recalculate the formula, I still think that my 1 second delay is correct. I'm using 11.0592 MHz100 x (65536-55536) x 1.085 us = 1.085 sec  ( approx. 1 sec)   (1/11.0592 Mhz) / 12 = 921,600 Hz   1 / 921,600 = 1.085 us   D8F0h = 55536 Now, my problem is :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. I suspected this is because of I didn't have any signal conditioning circuit for the ADC analog input. Can this be the problem ?? Vin is from LM35 temp sensor = 0.29 Vstepsize for ADC = 4.90 V / 256 = 19 mVDout is in decimal0.29 / 19mV = 15.263  CODE:<br />;Information :<br />;the code is initilaise as 2x16 although it is 1x16 <br />;because of the 8+8 configuration.<br />;the ninth position start at the address 40h<br />;&#091;00 01 02 03 04 05 06 07 41 42 43 44 45 46 47]<br />;#07h --> shift display to the left<br />ORG 0000H<br /><br />MOV TMOD, #0x01<br /><br />RS_lcd EQU P1.2<br />RW_lcd EQU P1.1<br />EN_lcd EQU P1.0<br />DAT_lcd EQU P0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;LCD PORT for DB0 to DB7<br /><br />INTR_adc equ P3.4<br />WR_adc equ P3.5<br />CS_adc equ P3.6<br />RD_adc equ P3.7<br />DAT_ADC equ P2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;ADC data pins P2<br />mux_add equ 30h<br />hundreds equ 31h<br />tens equ 32h<br />ones equ 33h<br /><br />aCALL INIT_LCD<br /><br />setb P3.5 &nbsp;;initialize wr_adc high<br />clr P3.6 &nbsp; ;set cs_adc always low<br />setb P3.7 &nbsp;;initialize rd_adc high<br /><br />clr P3.0 ;off LED connected to P3.0<br />clr P3.1 &nbsp;;off LED connected to P3.1<br /><br />mov mux_add, #00000101b ;MUX address for ADC0844<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; ;channel 2, single-ended mode<br />;==============================================================<br />disp_str macro string&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;Macro for sending string to LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;irpc char, &lt;string><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if nul 'char'<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exitm<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;endif<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mov a,#'char'<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lcall write_text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;endm<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;endm<br /><br />start : acall clear_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall conv_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; disp_str &lt;Temp:><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov P2, 0xFF &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;configure to read from port 2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall read_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall bin2dec<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall ascii4lcd_tens&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall write_text &nbsp; ;write tens to LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall ascii4lcd_ones&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall write_text &nbsp; ;write ones to LCD<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr rs_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov dat_lcd, #0C0h ;80h + 40h (instruction + lcd mapping address)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setb en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall delay_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall wait_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; disp_str &lt;Celcius><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;acall delay_500ms&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sjmp start<br />;====================================================<br />Bin2Dec:<br />&nbsp; &nbsp; &nbsp; &nbsp;mov b,#100d ;1100 0100<br />&nbsp; &nbsp; &nbsp; &nbsp;div ab<br />&nbsp; &nbsp; &nbsp; &nbsp;mov hundreds,a<br />&nbsp; &nbsp; &nbsp; &nbsp;mov a,b<br />&nbsp; &nbsp; &nbsp; &nbsp;mov b,#10d<br />&nbsp; &nbsp; &nbsp; &nbsp;div ab<br />&nbsp; &nbsp; &nbsp; &nbsp;mov tens,a<br />&nbsp; &nbsp; &nbsp; &nbsp;mov ones,b<br />&nbsp; &nbsp; &nbsp; &nbsp;ret<br />;=============================================<br />ascii4lcd_tens :<br />add A, #30h&nbsp; &nbsp; &nbsp;;add 30h to tens value<br />ret<br /><br />ascii4lcd_ones :<br />mov A, B<br />add A, #30h<br />ret<br />;=========================================================<br />conv_adc :<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mov dat_adc, mux_add ;load mux address into A<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb wr_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wait : jb intr_adc, wait&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ret<br /><br />read_adc : clr rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; nop&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; mov A, DAT_ADC &nbsp;;move ADC 8 bit result to A<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setb rd_adc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nop<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ret<br />;==========================================================<br />;===========================================================<br />WAIT_LCD : &nbsp;acall DELAY_2ms &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;RET<br /><br />INIT_LCD : &nbsp;clr en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV DAT_lcd, #38h &nbsp;;initialize lcd as 2x16&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aCALL WAIT_LCD<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr en_lcd<br />&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; CLR RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV DAT_lcd,#0Ch&nbsp; &nbsp; &nbsp; &nbsp; ;no cursor, no blinking of cursor&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aCALL WAIT_LCD<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV DAT_lcd,#06h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aCALL WAIT_LCD<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV DAT_lcd,#14h<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aCALL WAIT_LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />CLEAR_LCD :&nbsp; &nbsp; &nbsp;clr en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clr rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV DAT_lcd,#01h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acall DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aCALL WAIT_LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />WRITE_TEXT : clr en_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SETB RS_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clr rw_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MOV DAT_lcd, A&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SETB EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;acall DELAY_2ms<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CLR EN_lcd<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; aCALL WAIT_LCD<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RET<br />;===========================================================================<br />;Delay subroutines...<br />DELAY_50us: MOV R5, #1 &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;this is a 50 micro second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp;<br />REPEAT_4:&nbsp; &nbsp; &nbsp; &nbsp;MOV TH0, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xD2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_4:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; JNB TF0, BACK_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT_4<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />DELAY_33ms: MOV R5, #100 &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;this is a 33 mili second delay subroutine&nbsp; &nbsp; &nbsp; &nbsp; <br />REPEAT_3:&nbsp; &nbsp; &nbsp; &nbsp;MOV TH0, #0xFE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xCF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_3:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; JNB TF0, BACK_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT_3<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />DELAY_2ms: &nbsp;MOV R5, #100&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;this is a 2ms delay subroutine&nbsp; &nbsp;<br />REPEAT:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; MOV TH0, #0xFF<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK:&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; JNB TF0, BACK<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br /><br />DELAY_500ms: MOV r5, #100&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ;this is a 0.5 second delay subroutine&nbsp; &nbsp; <br />REPEAT_2:&nbsp; &nbsp; &nbsp; &nbsp;MOV TH0, #0xEE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0x00<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_2:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; JNB TF0, BACK_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ r5, REPEAT_2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />DELAY_1sec: MOV R5, #100&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;this is a 1 second delay subroutine&nbsp; &nbsp; &nbsp; <br />REPEAT_1:&nbsp; &nbsp; &nbsp; &nbsp;MOV TH0, #0xD8<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV TL0, #0xF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SETB TR0<br />BACK_1:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; JNB TF0, BACK_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TR0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CLR TF0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DJNZ R5, REPEAT_1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RET&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 />END<br />&nbsp;</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Arun Kumar V</dc:creator>
						<dc:subject></dc:subject>
						<description>Hi Freddy,I recalculate the formula, I still think that my 1 second delay is correct. I'm using 11.0592 MHzyour calculation is based on 12Mhz crystal freq, my guess proved correct that you are using 11.0592Meg xtal.so here is the calculation  for 10mSec delay using 11.0592 meg ( 10mS X 100 times =1sec):1) 10,000 divided by 1.085uS = 9216 decimal2) 65536 - 9216 = 56,320 decimal3) 56,320 d = 0DC00h4) TH0 = 0DCh , TL0 = 00hyou can cross check by multiplying 9216 X 1.085 = 9999.36 uSec but your values give a delay  of 10,000 X 1.085 = 10,850 uSec a delay about the variation in reading, i'll find let you where the error isArun</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t11195.html">
						<title>Re: ADC 0844 errorneous results. Help me.</title>
						<link>http://www.8051projects.net/forum-t11195.html</link>
						<dc:date>2009-01-08T08:54:51-08:00</dc:date>
						<dc:creator>Freddy</dc:creator>
						<dc:subject></dc:subject>
						<description>Yup, got it now. Thank you so much Arun    I think I'll switch to 12 MHz</description>
						</item>
				</rdf:RDF>