<?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/3004" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2009-07-22T14:10:29+02:00</updated>

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

		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2009-07-22T14:10:29+02:00</updated>

		<published>2009-07-22T14:10:29+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10254#p10254</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10254#p10254"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10254#p10254"><![CDATA[
<blockquote class="uncited"><div>Doesn't look like you could do it w/o extra hardware to split the clock &amp; data signal <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /> But then, it's late and I could easily miss something..</div></blockquote> meh, yeah 2 shift register would be best, but I know one other guy that did it with one avr. He decided to keep his code a hush though. <br /><br />I know when the signal is coming and the data is timed with in 6 ns.  So I can read at 6 ns intervals or watching a falling edge. <br /><br /><blockquote class="uncited"><div>another possibility would be to synchronize to the USB and receive it just after a keep-alive SOF (gives you about 1ms w/o any USB activity).</div></blockquote><br /><br />This may work, 1ms is more then enough for me to get the data. How do you detect this SOF ?<br /><br /><br />Hmm, but<br />I call my update func using the TIFR . update would need to know about the sof, would it be able to based on how I'm calling it.<br /><div class="codebox"><p>Code: </p><pre><code>/* Read the controller periodically*/<br />      if (TIFR &amp; (1&lt;&lt;OCF2))<br />      {<br />         TIFR = 1&lt;&lt;OCF2;<br /><br />         curGamepad-&gt;update();<br /><br />         /* Check what will have to be reported */<br />         for (i=0; i&lt;curGamepad-&gt;num_reports; i++) {<br />            if (curGamepad-&gt;changed(i+1)) {<br />               must_report |= (1&lt;&lt;i);<br />            }<br />         }<br />      }<br /></code></pre></div><br /><br />unless I could do something like this in my update function. <br /><br />wait for SOF, if not wait more, else do it.. This could introduce a 1m delay on my controller at max, not to bad. But my guess is I can not watch for the SOF with out running a full code loop.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Wed Jul 22, 2009 2:10 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Grendel]]></name></author>
		<updated>2009-07-22T11:22:02+02:00</updated>

		<published>2009-07-22T11:22:02+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10252#p10252</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10252#p10252"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10252#p10252"><![CDATA[
Doesn't look like you could do it w/o extra hardware to split the clock &amp; data signal <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /> But then, it's late and I could easily miss something.. <img class="smilies" src="./../../../images/smilies/icon_wink.gif" alt=";)" title="Wink" /> If it's not a random signal (ie. it's there on a fast period or you can trigger for it), another possibility would be to synchronize to the USB and receive it just after a keep-alive SOF (gives you about 1ms w/o any USB activity).<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=101">Grendel</a> — Wed Jul 22, 2009 11:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2009-07-21T14:32:28+02:00</updated>

		<published>2009-07-21T14:32:28+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10245#p10245</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10245#p10245"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10245#p10245"><![CDATA[
You know I thought about this after seeing the psx2 project.  Personally I feel the SPI could be used for this but not sure how I could get it to work. The device I'm talking to uses a two line async serial bus. The two serial data lines alternate between clock and data every bit. <br /> Would I be able to sample and talk to two lines with it?<br /><br />here is the signal I'm trying t read.<br /><br /><img src="http://img31.picoodle.com/img/img31/4/5/12/f_helpm_907a2d7.jpg" class="postimage" alt="Image" /><br /><br />If my thoughts are right maybe I could use a 1 bit buffer sampling  SDCKA 6 cycles Prior to a watch for a falling edge on SDCKB, and when it sees one, read both the current bit on SDCKB and the buffered bit SDCKA. This would allow one pin to be looked at. And allow me to only deal with a 1MHz clock.<br /><br />Now If this is plausible.. how to ASM code it? I guess I could write it long-hand and and go to disassembly and see. but I'm not even surch how to use the SPI to get the job done ;(<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Tue Jul 21, 2009 2:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Grendel]]></name></author>
		<updated>2009-07-21T10:44:07+02:00</updated>

		<published>2009-07-21T10:44:07+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10236#p10236</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10236#p10236"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10236#p10236"><![CDATA[
Any chance you could &quot;miss&quot;-use the SPI interface for reading those bits ?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=101">Grendel</a> — Tue Jul 21, 2009 10:44 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2009-07-20T22:13:08+02:00</updated>

		<published>2009-07-20T22:13:08+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10229#p10229</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10229#p10229"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10229#p10229"><![CDATA[
If I'm working with NS timing, will the usb interrupt get in the way?  <br /><br />Assuming yes.. I know I can disable it and I get 20 cycles before I must re enable but I need to do some NS work for a bit more then that. I'm reading 32 bits of data and they are 6 NS apart. Not sure but I may be able to watch for a falling edge to time it better. If I can figure out how to do that in asm.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Mon Jul 20, 2009 10:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Grendel]]></name></author>
		<updated>2009-07-15T20:31:55+02:00</updated>

		<published>2009-07-15T20:31:55+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10172#p10172</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10172#p10172"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10172#p10172"><![CDATA[
<blockquote><div><cite>ulao wrote:</cite>Here is what I want to do . Data will be coming across PB5 as a vary fast rate. I need to grab the current condition ( hi/low) and store it in a var for later use all with in a few nops. Later ( after the asm )I need to use that var.</div></blockquote><br />avr-libc gives you native C access to all the registers, I don't think you'll need an inline assembler at all for that. Something like<br /><br /><div class="codebox"><p>Code: </p><pre><code>#include &lt;avr/io.h&gt;<br /><br />uint8_t<br />    arr&#91;n&#93;, i, *p ;<br /><br />for ( i = n, p = arry ; i-- ; )<br />{<br />    *p++ = PINB ;<br />    asm (&quot;nop\n\t&quot; ) ; // may not be necessary<br />}</code></pre></div><br />should do nicely. Check out the *.lss file created by the compiler to verify the timing, fine tune w/ nops accordingly.<br /><br />For a in-depth discussion of the asm interface check out the file doc/gcc/HTML/gcc-4.3.2/gcc/Extended-Asm.html in the directory where you installed WinAvr (should be the same for avr-gcc).<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=101">Grendel</a> — Wed Jul 15, 2009 8:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2009-07-15T14:22:22+02:00</updated>

		<published>2009-07-15T14:22:22+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10166#p10166</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10166#p10166"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10166#p10166"><![CDATA[
<blockquote><div><cite>Grendel wrote:</cite>Nope, it's an inline macro.</div></blockquote> Yeah  I recently learned the wonders of inline and speed. WOW.<br /><br /><br />Ok so it turns out out to be able to time this pattern I need to use all ASM. I'm trying to learn asm for the first time. I'm using asm code in c, not an S file but having learning struggles. Any tips, advice or, tuts that would help specific to avr asm calls? I have learned how to get data from a port and dump to a register, and take a bit from that register put on a other registers bit. But for the life of me a can not get this register to a usable variable in my code.<br /><br />Here is what I want to do . Data will be coming across PB5 as a vary fast rate. I need to grab the current condition ( hi/low) and store it in a var for later use all with in a few nops. Later ( after the asm )I need to use that var.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Wed Jul 15, 2009 2:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Grendel]]></name></author>
		<updated>2009-07-15T09:50:24+02:00</updated>

		<published>2009-07-15T09:50:24+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10161#p10161</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10161#p10161"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10161#p10161"><![CDATA[
<blockquote><div><cite>horo wrote:</cite>You will have overhead from calling the function too [..]</div></blockquote><br />Nope, it's an inline macro.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=101">Grendel</a> — Wed Jul 15, 2009 9:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[horo]]></name></author>
		<updated>2009-07-15T09:31:10+02:00</updated>

		<published>2009-07-15T09:31:10+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10160#p10160</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10160#p10160"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10160#p10160"><![CDATA[
FROM avr-libc manual:<br /><blockquote class="uncited"><div>void _delay_us  ( double  __us   )   <br />Perform a delay of __us microseconds, using _delay_loop_1().</div></blockquote><br /><blockquote class="uncited"><div>void _delay_loop_1  ( uint8_t  __count   )   <br />Delay loop using an 8-bit counter __count, so up to 256 iterations are possible. (The value 256 would have to be passed as 0.) The loop executes three CPU cycles per iteration, not including the overhead the compiler needs to setup the counter register.</div></blockquote><br />You will have overhead from calling the function too - use &quot;nop nop nop&quot; !<br /><br />Ciao Martin<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=891">horo</a> — Wed Jul 15, 2009 9:31 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Grendel]]></name></author>
		<updated>2009-07-14T21:41:26+02:00</updated>

		<published>2009-07-14T21:41:26+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10149#p10149</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10149#p10149"/>
		<title type="html"><![CDATA[Re: nanoseconds]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3004&amp;p=10149#p10149"><![CDATA[
<blockquote><div><cite>ulao wrote:</cite>So with C I could then write _delay_us( 0.25 ) and this should give my 250 ns?</div></blockquote><br />Yes, but keep the resolution (1/f) in mind. I would use the three nop's tho since results in exactly 250ns.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=101">Grendel</a> — Tue Jul 14, 2009 9:41 pm</p><hr />
]]></content>
	</entry>
	</feed>
