<?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-07T21:44:20-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-t6661.html" />
						<rdf:li rdf:resource="http://www.8051projects.net/forum-t6661.html" />
				</rdf:Seq>
				</items>
				</channel>
						<item rdf:about="http://www.8051projects.net/forum-t6661.html">
						<title>10bit Right justified encoded char</title>
						<link>http://www.8051projects.net/forum-t6661.html</link>
						<dc:date>2009-01-07T21:44:20-08:00</dc:date>
						<dc:creator></dc:creator>
						<dc:subject></dc:subject>
						<description>hello admin,i have a problem reading the 10-bit right justified 2 byte data from the PIC. i'm using matlab to read the ADC. here is my PIC C code;CODE:main&#40;&#41;<br />&#123;<br />&nbsp; &nbsp;long int adcValue; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //16-bit A2D reading storage<br />&nbsp; &nbsp;char adcHI, adcLO; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //8-bit real time frames storage<br />&nbsp; &nbsp;setup_adc_ports&#40;A_ANALOG&#41;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //set all ADC pins to analog<br />&nbsp; &nbsp;setup_adc&#40;ADC_CLOCK_INTERNAL&#41;; &nbsp; &nbsp; &nbsp; &nbsp; //enable A2D module<br />&nbsp; &nbsp;set_adc_channel&#40;0&#41;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//read channel 0<br />&nbsp; &nbsp;delay_us&#40;20&#41;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//delay for sampling cap to charge<br />&nbsp; &nbsp;while&#40;TRUE&#41;<br />&nbsp; &nbsp;&#123;<br />&nbsp; &nbsp; &nbsp; adcValue = read_adc&#40;&#41;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//start conversion<br />&nbsp; &nbsp; &nbsp; adcHI = &#40;char&#41;&#40;&#40;adcValue>>5&#41;& 0x1f&#41;; &nbsp; &nbsp; &nbsp;// 0|0|0|d9|d8|d7|d6|d5<br />&nbsp; &nbsp; &nbsp; adcLO = &#40;char&#41;&#40;&#40;adcValue &amp; 0x1f&#41;|0x80&#41;; &nbsp; // 1|0|0|d4|d3|d2|d1|d0<br />&nbsp; &nbsp; &nbsp; putc&#40;adcHI&#41;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Transmit Byte 1 (d9...d5)<br />&nbsp; &nbsp; &nbsp; putc&#40;adcLO&#41;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Transmit Byte 2 (d4...d0)<br />&nbsp; &nbsp; &nbsp; delay_ms&#40;5&#41;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //small delay before read<br />&nbsp; &nbsp;&#125;<br />&#125;using hyperterminal and other serial port monitors, i can get the ADC data. but with matlab  it gives me the error: inputBufferSize must be greater than zero which means no data is in the port. initialization of the serial port with the matlab code was made, serial object creation, serial settings; BaudRate @9600 as with the PIC,8bits, Parity=noneCODE: s = serial&#40;'COM1'&#41;;<br />&nbsp; &nbsp;fopen&#40;s&#41;;<br />&nbsp; &nbsp;set &#40;s, 'BaudRate', 9600&#41;;<br />&nbsp; &nbsp;data = fread&#40;s,s.BytesAvailable&#41;;<br />&nbsp; &nbsp;n = length&#40;data&#41;;<br />i=1;<br />&nbsp; &nbsp;while &#40;i&lt;n/2&#41;<br />&nbsp; &nbsp;&#123;<br />&nbsp; &nbsp;&#125;<br />&nbsp; &nbsp;end<br />&nbsp; &nbsp;fclose&#40;s&#41;;<br />&nbsp; &nbsp;delete&#40;s&#41;;<br />&nbsp; &nbsp;clear&#40;s&#41;;how can i decode the 8 bit encoded character send by the pic?</description>
						</item>
						<item rdf:about="http://www.8051projects.net/forum-t6661.html">
						<title>Re: 10bit Right justified encoded char</title>
						<link>http://www.8051projects.net/forum-t6661.html</link>
						<dc:date>2009-01-07T21:44:20-08:00</dc:date>
						<dc:creator>sashijoseph</dc:creator>
						<dc:subject></dc:subject>
						<description>You probably need to specify input buffer size.set(s, 'InputBufferSize', 512) ;</description>
						</item>
				</rdf:RDF>