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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2011-02-26T09:41:49+02:00</updated>

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

		<entry>
		<author><name><![CDATA[Augend]]></name></author>
		<updated>2011-02-26T09:41:49+02:00</updated>

		<published>2011-02-26T09:41:49+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17711#p17711</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17711#p17711"/>
		<title type="html"><![CDATA[Re: usbPoll() in Timer0 interrupt routine.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17711#p17711"><![CDATA[
If you put big codes in main loop your device will not be seen in next system enumeration. calling usbpoll() in short intervals is mandatory for device recognition. if you are using a watchdog dont forget to reset it during your calculations.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=4965">Augend</a> — Sat Feb 26, 2011 9:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[maxi]]></name></author>
		<updated>2011-02-25T03:57:47+02:00</updated>

		<published>2011-02-25T03:57:47+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17699#p17699</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17699#p17699"/>
		<title type="html"><![CDATA[Re: usbPoll() in Timer0 interrupt routine.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17699#p17699"><![CDATA[
You should be calling usbPoll() from the main loop. It is a bad idea in any case to call a subroutine from an ISR<br /><blockquote class="uncited"><div>6.- Interrupts and Timing - Make sure that you're not using interrupts higher than the interrupt you have set for VUSB. Also make sure you're not disabling interrupts for longer than a few milliseconds, or that you have more than 10ms between calls to usbPoll(). A common mistake is to have sections of floating-point calculations in a main loop which does call usbPoll(), however, keep in mind that floating-point math is EXTREMELY slow, it may be worthwhile to place usbPoll() before and after these calculations.</div></blockquote><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2570">maxi</a> — Fri Feb 25, 2011 3:57 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[maciek_nh]]></name></author>
		<updated>2011-02-24T22:54:31+02:00</updated>

		<published>2011-02-24T22:54:31+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17694#p17694</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17694#p17694"/>
		<title type="html"><![CDATA[usbPoll() in Timer0 interrupt routine.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=5476&amp;p=17694#p17694"><![CDATA[
Hello,<br /><br />I wrote following program:<br /><br /><div class="codebox"><p>Code: </p><pre><code>#include &lt;avr/io.h&gt;<br />#include &lt;avr/wdt.h&gt;<br />#include &lt;avr/interrupt.h&gt;  /* for sei() */<br />#include &lt;util/delay.h&gt;     /* for _delay_ms() */<br />#include &lt;avr/pgmspace.h&gt;   /* required by usbdrv.h */<br />#include &quot;usbdrv/usbdrv.h&quot;<br />#include &quot;usbdrv/requests.h&quot;       /* The custom request numbers we use */<br />#include &quot;usb_interface.h&quot;<br />#include &quot;lcd.h&quot;<br /><br />int main(void)<br />{<br />   DDRB = 0xFF;<br />   DDRD = 0xF0;         //D+ and D- both as input;<br />   <br />   // usb init      <br />    usbInit();<br />    usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */<br />    usbDeviceConnect();<br />   // interrupt enable<br />    sei();      <br /><br />   //Timer0 init<br />   TCCR0 = (1&lt;&lt;CS00);<br />   TIMSK =  (1&lt;&lt;TOIE0);<br />   TCNT0 = 223;   <br /><br />   // init other devices<br />   lcd_init();   <br /><br />   <br />    for(;;){}<br />    return 0;<br />}<br /><br />/* ------------------------------------------------------------------------- */<br /><br />ISR(TIMER0_OVF_vect)<br />{   <br />   usbPoll();<br />   TCNT0 = 230;<br />}<br /></code></pre></div><br /><br />When I connect my device to my computer, the device is not recognized. There is something wrong with Timer0 interrupt routine. I do not even know if it is possible to place usbPoll() in interrupt routine. If I put usbPoll() to 'for' loop everything works fine. Could someone tell me if it is possible to call usbPoll() in any interrupt routine. If yes, please write how.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=4955">maciek_nh</a> — Thu Feb 24, 2011 10:54 pm</p><hr />
]]></content>
	</entry>
	</feed>
