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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2013-02-04T19:47:00+02:00</updated>

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

		<entry>
		<author><name><![CDATA[simtr]]></name></author>
		<updated>2013-02-04T19:47:00+02:00</updated>

		<published>2013-02-04T19:47:00+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1596&amp;p=24685#p24685</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=24685#p24685"/>
		<title type="html"><![CDATA[Re: Question: usbpoll()]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=24685#p24685"><![CDATA[
<blockquote><div><cite>christian wrote:</cite>You need a timer interrupt which sets a global volatile variable &quot;timerInterruptOccurred&quot; every millisecond.<br /></div></blockquote><br /><br />Can you tell me how?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=19512">simtr</a> — Mon Feb 04, 2013 7:47 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2008-07-31T12:21:42+02:00</updated>

		<published>2008-07-31T12:21:42+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5889#p5889</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5889#p5889"/>
		<title type="html"><![CDATA[Question: usbpoll()]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5889#p5889"><![CDATA[
If no data must be processed (99% of the calls), it does two global variable loads, two comparisons and returns. You must call it at least every 50 ms, see usbdrv.h for more info about the API.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Thu Jul 31, 2008 12:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-07-31T07:47:35+02:00</updated>

		<published>2008-07-31T07:47:35+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5887#p5887</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5887#p5887"/>
		<title type="html"><![CDATA[Question: usbpoll()]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5887#p5887"><![CDATA[
how often must usbPoll(); be called and how long does it take to complete it?<p>Statistics: Posted by Guest — Thu Jul 31, 2008 7:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2008-07-29T17:37:37+02:00</updated>

		<published>2008-07-29T17:37:37+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5872#p5872</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5872#p5872"/>
		<title type="html"><![CDATA[Question: usbpoll()]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5872#p5872"><![CDATA[
usbPoll() returns within a few microseconds, unless a message was received. If a message was received, it calls one of your functions (e.g. usbFunctionSetup()) and returns then. usbPoll() NEVER blocks by itself.<br /><br />The code example you gave won't work because you don't call usbPoll() often enough. You want something like this:<br /><br /><div class="codebox"><p>Code: </p><pre><code>    int cnt = 0;<br />    for&#40;;;&#41;&#123;<br />        usbPoll&#40;&#41;;<br />        if&#40;timerInterruptOccurred&#41;&#123;<br />            timerInterruptOccurred = 0;<br />            if&#40;cnt++ &gt;= 500&#41;&#123;<br />                cnt = 0;<br />                PORT_LED ^= &#40;1 &lt;&lt; PAD_LED&#41;;<br />            &#125;<br />        &#125;<br />    &#125;<br /></code></pre></div><br /><br />You need a timer interrupt which sets a global volatile variable &quot;timerInterruptOccurred&quot; every millisecond.<br /><br />In principle, you can also do it like this:<br /><div class="codebox"><p>Code: </p><pre><code>    char cnt = 0;<br />    for&#40;;;&#41;&#123;<br />        usbPoll&#40;&#41;;<br />        wait_10ms&#40;1&#41;; <br />        if&#40;cnt++ &gt;= 5&#41;<br />            cnt = 0;<br />            PORT_LED ^= &#40;1 &lt;&lt; PAD_LED&#41;;<br />        &#125;<br />    &#125;<br /></code></pre></div><br /><br />But the timing will be unreliable because wait_10ms() does not account for time spent in interrupt routines (such as the USB interrupt).<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Tue Jul 29, 2008 5:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Psychomax]]></name></author>
		<updated>2008-07-22T23:56:05+02:00</updated>

		<published>2008-07-22T23:56:05+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5828#p5828</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5828#p5828"/>
		<title type="html"><![CDATA[Question: usbpoll()]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1596&amp;p=5828#p5828"><![CDATA[
Hello together.<br /><br />First i must say my english is not that good. So please be nice! <img class="smilies" src="./../../../images/smilies/icon_wink.gif" alt=";)" title="Wink" /><br /><br />So here is my question. I really don't know how to use the function usbpoll(). Or the other way arround, i don't know how to use it with my problem. <img class="smilies" src="./../../../images/smilies/icon_smile.gif" alt=":)" title="Smile" /><br /><br />First here is a example code. It just make the LED on and off.<br /><br /><div class="codebox"><p>Code: </p><pre><code>#define WAIT_TIME 100<br /><br />....<br /><br />int main&#40;&#41;<br />&#123;<br />    // LED-Port auf OUT<br />    DDR_LED  |= &#40;1 &lt;&lt; PAD_LED&#41;;<br /><br />    // Timer1 initialisieren<br />    timer1_init&#40;&#41;;<br /><br />    // Interrupts aktivieren<br />    sei&#40;&#41;;<br /><br />    // Endlosschleife<br />    // Die LED ist jeweils 1 Sekunde an und 1 Sekunde aus,<br />    // blinkt also mit einer Frequenz von 0.5 Hz<br />    while &#40;1&#41;<br />    &#123;<br />        PORT_LED |= &#40;1 &lt;&lt; PAD_LED&#41;;<br />        wait_10ms &#40;WAIT_TIME&#41;;<br /><br /><br />        PORT_LED &amp;= ~&#40;1 &lt;&lt; PAD_LED&#41;;<br />        wait_10ms &#40;WAIT_TIME&#41;;<br />    &#125;<br />&#125;<br /></code></pre></div><br /><br />So know i wanna change the &quot;WAIT_TIME&quot; via USB. I modifiy this code to that.<br /><br /><div class="codebox"><p>Code: </p><pre><code>#define WAIT_TIME 100<br /><br />....<br /><br />int main&#40;&#41;<br />&#123;<br />    <br />    ... USB INIT etc....<br /><br />      while &#40;1&#41;<br />    &#123;<br />        usbpoll&#40;&#41;;//CHANGE WAIT_TIME and GOES ON<br /><br />        PORT_LED |= &#40;1 &lt;&lt; PAD_LED&#41;;<br />        wait_10ms &#40;WAIT_TIME&#41;;<br /><br /><br />        PORT_LED &amp;= ~&#40;1 &lt;&lt; PAD_LED&#41;;<br />        wait_10ms &#40;WAIT_TIME&#41;;<br />    &#125;<br />&#125;<br />&#125;<br /></code></pre></div><br /><br />Will that work?! So the problem is for me does &quot;usbpoll()&quot; only poll, when a interrupt comes or polling everytime, so the it has a effect on the timer of the LED?! <br /><br />Hope you know what i mean... <img class="smilies" src="./../../../images/smilies/icon_smile.gif" alt=":)" title="Smile" /><br /><br />So shortly say. Is &quot;usbpoll()&quot; everytime aktiv or only when the host wants an action. Or the otherway arround will any code after &quot;usbpoll()&quot; be called?!<br /><br />LG Max<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1230">Psychomax</a> — Tue Jul 22, 2008 11:56 pm</p><hr />
]]></content>
	</entry>
	</feed>
