<?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><a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/in/" target="_blank"><img alt="Creative Commons License" width="80" height="15" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/2.5/in/80x15.png" target="_blank" /></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/in/" target="_blank">Creative Commons Attribution-Noncommercial 2.5 India License</a>.<a href='http://www.8051projects.net/disclaimer.htm' target='_blank' />Rickey's World Disclaimer</a></copyright>
				<managingEditor>Ajay Bhargav - contact@nospam.com</managingEditor>
				<webMaster>contact@nospam.com</webMaster>
				<pubDate>Mon, 01 Dec 2008 11:58:32 -0800</pubDate>
				<lastBuildDate>Mon, 01 Dec 2008 11:58:32 -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>SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[I am reading the ADC of the master controller and sending the data to the slave through SPI.<br /><br />Master is sending the data accurately, but slave is receiving in this fashion<br /><br />Master send = 179<br />Slave read = 179  210  218  51  46  124  168  254  232  201  179  ..........<br />This means that I  receive the correct data  after 8 or 9 bytes as you can see the pattern shown above. Another thing is that I am sending this data on hyper terminal.<br /><br />My code for master and slave is given below.<br /><br /><strong class='bbcode bold'>Master Code:</strong><br /><br /><br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><br /><span style="color: #339933;">#include &lt;16F877A.h&gt;//</span><br /><span style="color: #339933;">#fuses NOWDT,NOPROTECT,XT,NOLVP,PUT</span><br /><span style="color: #339933;">#use delay(clock=4000000)</span><br /><span style="color: #339933;">#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)</span><br /><span style="color: #993333;">float</span> val=<span style="color: #cc66cc;">0</span>;<br />int8 data=<span style="color: #cc66cc;">0</span>;<br /><br /><br /><br /><br /><br /><span style="color: #339933;">#int_TIMER0</span><br /><br /><span style="color: #993333;">void</span> pick_sample<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />set_timer0<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>;<br />set_adc_channel<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />delay_us<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;<br />val = read_adc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />data = <span style="color: #66cc66;">&#40;</span>int8<span style="color: #66cc66;">&#41;</span>val;<br /><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br /><br />setup_timer_0<span style="color: #66cc66;">&#40;</span>RTCC_INTERNAL|RTCC_DIV_16<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp;<br />set_timer0<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">150</span><span style="color: #66cc66;">&#41;</span>;<br /><br />enable_interrupts<span style="color: #66cc66;">&#40;</span>int_rtcc<span style="color: #66cc66;">&#41;</span>;<br />enable_interrupts<span style="color: #66cc66;">&#40;</span>global<span style="color: #66cc66;">&#41;</span>;<br /><br />setup_adc_ports<span style="color: #66cc66;">&#40;</span>all_analog<span style="color: #66cc66;">&#41;</span>;<br />setup_adc<span style="color: #66cc66;">&#40;</span>adc_clock_internal<span style="color: #66cc66;">&#41;</span>;<br /><br />setup_spi<span style="color: #66cc66;">&#40;</span> SPI_MASTER | SPI_H_TO_L | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16 <span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br /><br />spi_write<span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span>;<br /><a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span>data = %u dataf = %f&quot;</span>,data,val<span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br />&nbsp;</div></div><br /><br /><br /><strong class='bbcode bold'>Slave code:</strong><br /><br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><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; &nbsp; &nbsp;<br /><span style="color: #808080; font-style: italic;">//SLAVE program</span><br /><br /><span style="color: #339933;">#include &lt;16F877A.h&gt;//</span><br /><span style="color: #339933;">#fuses NOWDT,NOPROTECT,XT,NOLVP,PUT</span><br /><span style="color: #339933;">#use delay(clock=4000000)</span><br /><span style="color: #339933;">#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)</span><br /><br />int8 data=<span style="color: #cc66cc;">0</span>;<br /><br /><br /><span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br /><br />setup_spi<span style="color: #66cc66;">&#40;</span>SPI_SLAVE|SPI_H_TO_L|SPI_SS_DISABLED<span style="color: #66cc66;">&#41;</span>;<br /><br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; output_high<span style="color: #66cc66;">&#40;</span>PIN_C4<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; output_high <span style="color: #66cc66;">&#40;</span>PIN_C5<span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>SPI_DATA_IS_IN<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = spi_read<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output_b<span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output_toggle<span style="color: #66cc66;">&#40;</span>PIN_D4<span style="color: #66cc66;">&#41;</span>;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span> data = %u&quot;</span>,data<span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span></div></div><br /><br /><br />Please help me in this regard. <img src='http://www.8051projects.net/e107_images/emotes/yahoo/17.gif' alt='' style='vertical-align:middle; border:0' />  <br />]]></description>
<pubDate>Thu, 13 Mar 2008 02:25:14 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
						<item>
						<title>Re: SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[i do not understand this..<br />you are sending one byte and on receiver side you are getting bytes like 8 or 9 bytes...  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/7.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>Ajay&lt;contact@nospam.com&gt;</author>
<pubDate>Thu, 13 Mar 2008 02:57:01 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
						<item>
						<title>Re: SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[I am sending from master 179 continuously, while slave is receiving the correct byte after 8 or 9th byte.That is correct data received after every 8th or 9th byte.  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/17.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>Hanzala&lt;hanzala1409@nospam.com&gt;</author>
<pubDate>Fri, 14 Mar 2008 07:30:56 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
						<item>
						<title>Re: SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[can you explain me in the slave code what are you doing here? and why?<br /><br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;">output_b<span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />output_toggle<span style="color: #66cc66;">&#40;</span>PIN_D4<span style="color: #66cc66;">&#41;</span>;<br />&nbsp;</div></div><br />]]></description>
<author>Ajay&lt;contact@nospam.com&gt;</author>
<pubDate>Fri, 14 Mar 2008 21:41:22 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
						<item>
						<title>Re: SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[By toggling D4 I am just want to make sure that slave is receiving the data and I am sending this data on port B. I have attached LED's on Port B and I just want to see the data on portB as well. <img src='http://www.8051projects.net/e107_images/emotes/yahoo/7.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>Hanzala&lt;hanzala1409@nospam.com&gt;</author>
<pubDate>Sun, 16 Mar 2008 22:13:49 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
						<item>
						<title>Re: SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[try doing this way...<br />in slave controller setup SPI as..<br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;">setup_spi<span style="color: #66cc66;">&#40;</span>SPI_SLAVE|SPI_L_TO_H|SPI_SS_DISABLED<span style="color: #66cc66;">&#41;</span>;</div></div><br />i mean.. L->H data transition.. please do it the right way..<br /><br />The thing is.. master put data on o/p pin on H->L transition and slave read on L->H transition, this ensures that data is transfered properly..<br /><br />Thats the reason you are getting correct data after exact 8 bits.. Everything will be fine if you just understand the reason..<br /><br />Make the changes and try again..]]></description>
<author>Ajay&lt;contact@nospam.com&gt;</author>
<pubDate>Mon, 17 Mar 2008 13:38:08 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
						<item>
						<title>Re: SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[It is still not working properly. May be it is a synchronization problem. Does any one has a program which he has tried himself?<br /><br />Can any one tell me that "if I donot use SPI_READ() function, but read the data from SSPBUF register", than how can I read SSPBUF in C?????? <img src='http://www.8051projects.net/e107_images/emotes/yahoo/102.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>Hanzala&lt;hanzala1409@nospam.com&gt;</author>
<pubDate>Thu, 10 Apr 2008 01:34:14 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
						<item>
						<title>Re: SPI interfacing problem between two 16F877A</title>
<link>http://www.8051projects.net/forum-t7020.html</link>
<description><![CDATA[hello,<br /><br />  Maybe the 'master' is running (and sending data) faster  than the slave (because it has few instructions). Therefore, the data in the slave PIC gets corrupted. If I were you I would put a delay in the master and test it again. <br /><br />BTW: Why did you put in the slave code the <br />    output_high(PIN_C4);<br />    output_high (PIN_C5);<br /><br />  pin_c4 is ther SDI and and C5 is the SDO]]></description>
<author>Rocha&lt;fabio.rocha@nospam.com&gt;</author>
<pubDate>Mon, 14 Apr 2008 06:22:11 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t7020.html</guid>
</item>
				</channel>
				</rss>