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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2009-06-04T18:02:39+02:00</updated>

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

		<entry>
		<author><name><![CDATA[mschumann]]></name></author>
		<updated>2009-06-04T18:02:39+02:00</updated>

		<published>2009-06-04T18:02:39+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=2837&amp;p=9627#p9627</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=2837&amp;p=9627#p9627"/>
		<title type="html"><![CDATA[[SOLVED] RC5 and VUSB]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=2837&amp;p=9627#p9627"><![CDATA[
Has anyone managed to get an rc5 (infrared remote control) decoding and vusb running both on a chip with 16 MHz or less?<br /><br />The solution to the Problem was to enable interrupt within the polling timer so that it doesnt block the USB interrupts. I nearly went crazy because the USB stack crashed when I used a timer at F_CPU/1024 with that code without the highligthed sei(); With the sei(); everything runs like clockwork since the rc5 decoding is not too time critical.<br /><br /><div class="codebox"><p>Code: </p><pre><code>ISR(TIMER0_OVF_vect)<br />{<br />   // triggert FCPU/1024, 64µs<br />   <br />   TIMSK &amp;= ~(1 &lt;&lt; TOIE0);<br />   TCNT0 = -1;<br />        <br />   &#91;b&#93;sei();&#91;/b&#93;<br />   <br />   uint16_t tmp = rc5_tmp;<br />   <br />   if (++rc5_time &gt; PULSE_MAX) {<br />      if (!(tmp &amp; 0x4000) &amp;&amp; tmp &amp; 0x2000) rc5_data = tmp;<br />      tmp = 0;<br />    }            <br />    <br />   if ((rc5_bit ^ PIND) &amp; (1 &lt;&lt; PIND3)) {      <br />      rc5_bit = ~rc5_bit;   <br /><br />      if (rc5_time &lt; PULSE_MIN) tmp = 0;<br />      if (!tmp || rc5_time &gt; PULSE_1_2) {   <br />         if (!(tmp &amp; 0x4000)) tmp &lt;&lt;= 1;<br />         if (!(rc5_bit &amp; 1&lt;&lt;PIND3))   tmp |= 1;<br />          rc5_time = 0;   <br />      }<br />      <br />   }<br />   rc5_tmp = tmp;<br />   <br />   TIMSK |= (1 &lt;&lt; TOIE0); <br />}<br />)</code></pre></div><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1744">mschumann</a> — Thu Jun 04, 2009 6:02 pm</p><hr />
]]></content>
	</entry>
	</feed>
