<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/2931" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2009-06-28T04:23:18+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/2931</id>

		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2009-06-28T04:23:18+02:00</updated>

		<published>2009-06-28T04:23:18+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=2931&amp;p=9931#p9931</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=2931&amp;p=9931#p9931"/>
		<title type="html"><![CDATA[help with code snipit.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=2931&amp;p=9931#p9931"><![CDATA[
Hey all, I want to adapt the ps2 example code in to my project. There are few lines I just dont understand. I'm sure its some sort of interrupt code but I need to change the pins and dont understand it.<br /><br />is SPCR tied to port b, and I need port c's register, as far as I can tell from the data sheet its just a Control Register? <br /><br /> This code uses port B, I need it to use port C, and also changes the pin assignments. <br />Here is what I get from the SPCR setting. <br /><br /><strong class="text-strong">[</strong>int  not enable the <strong class="text-strong">]</strong>,<strong class="text-strong"> [</strong>enable SPI <strong class="text-strong">]</strong>, <strong class="text-strong">[</strong> Master SPI mode ( in bit 5 instead of 4?) <strong class="text-strong">]</strong>,<strong class="text-strong">[</strong> bit 4 gets SPR1 that should be in bit 1<strong class="text-strong">]</strong>,<strong class="text-strong">[</strong> bit 3 gets SPR1 that should be in bit 0<strong class="text-strong">]</strong>,<strong class="text-strong">[</strong>bit 2 gets DORD instead of CPHA<strong class="text-strong">]</strong>,<strong class="text-strong">[</strong>bit 2 gets CPHA instead of SPR1<strong class="text-strong">]</strong>,<strong class="text-strong">[</strong>bit 2 gets CPOL instead of SPR0<strong class="text-strong">]</strong>. Are these not order depended or something ?<br /><br /><div class="codebox"><p>Code: </p><pre><code>void spi_mInit()<br />{<br />   // SPI, master, clock/128 = 93.75khz (187.5 didn't work...)<br />   SPCR = (1&lt;&lt;SPE)|(1&lt;&lt;MSTR)|(1&lt;&lt;SPR1)|(1&lt;&lt;SPR0)|(1&lt;&lt;DORD)|(1&lt;&lt;CPHA)|(1&lt;&lt;CPOL);<br />}<br />unsigned char spi_mSend(unsigned char podatek)   //straight from documentation<br />{<br /><br />   // Gets information, sends it, waits untill it's sent, then reads the same register (used for both Input and Output) and returns it<br /><br />   /* Start transmission */<br />   SPDR = podatek;<br />   while(!(SPSR &amp; (1&lt;&lt;SPIF)));<br /><br />   return SPDR;<br />}</code></pre></div><br />Later on it does a ps2buffer[0]=spi_mSend(0x01); but how does it know what pin to look at?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Sun Jun 28, 2009 4:23 am</p><hr />
]]></content>
	</entry>
	</feed>
