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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2018-08-20T19:17:46+02:00</updated>

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

		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2018-08-20T19:17:46+02:00</updated>

		<published>2018-08-20T19:17:46+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11102&amp;p=34595#p34595</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=34595#p34595"/>
		<title type="html"><![CDATA[Re: v-usb not really good for control transfers after all.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=34595#p34595"><![CDATA[
Just want to add that the solution is no good once you have multiple devices.  The flag is set off for any traffic. I guess I'd have to wait for the correct matching address but it may be too late at that point.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Mon Aug 20, 2018 7:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2018-08-01T13:55:47+02:00</updated>

		<published>2018-08-01T13:55:47+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11102&amp;p=34533#p34533</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=34533#p34533"/>
		<title type="html"><![CDATA[Re: v-usb not really good for control transfers after all.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=34533#p34533"><![CDATA[
I was able to find a solution. <br /><br />In the asm includes for your chip just add a flag.  I used 0 for flag set, 1 for flag not set. <br /><br />waitForJ:<br /><strong class="text-strong">clr r3; <br />sts _Control_Data, r3<br />//sbi PORTB, 2; ;debug<br />//cbi PORTB, 2; ;debug</strong><br /><br />debug it to see how it works. It constantly sets a flag when any data goes over the usb bus. <br /><br />to use it I do this.<br /><br />(make sure to run this code after the usb poll so things are lined up right).<br /><strong class="text-strong">_Control_Data=_Control_Data_not_set;<br />curGamepad-&gt;update();<br />if (_Control_Data == _Control_Data_set) _DoNotReport=1;</strong><br /><br />So if data was being sent when my code was running I skip reporting it to the host. <br /><br /><br />As I learned there is no free slots during setup packets. They can come at any time and can NACK for a long time. You must allow then to occur or the host gets angry. So let it happen and check after. At a spam rate of 2 ms apart, I sampled 10 updates skipped out of 100. That's not too bad... The only real gotcha here is that if you need to do anything longer then 300us it will not happen if the host needs to send any control transfers.  I'd suggest one of two options. 1) scheduled a point where the host takes a break. I.E host sends report 1,2,3,4 then waits for some period of time. 2) make a get DND report to check when the client needs to do some work. This is no much good for timely work.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Wed Aug 01, 2018 1:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2017-11-14T18:36:10+02:00</updated>

		<published>2017-11-14T18:36:10+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33293#p33293</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33293#p33293"/>
		<title type="html"><![CDATA[Re: v-usb not really good for control transfers after all.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33293#p33293"><![CDATA[
Idea will not work because this function is only called based on the interrupt.  I'd have to step back further.  Unsure where to look at the moment, abandoning this idea for now.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Tue Nov 14, 2017 6:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2017-11-10T18:23:45+02:00</updated>

		<published>2017-11-10T18:23:45+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33268#p33268</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33268#p33268"/>
		<title type="html"><![CDATA[Re: v-usb not really good for control transfers after all.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33268#p33268"><![CDATA[
One small addition. It may be wise to check for the interrupt arrest before enabling.<br /><br />usbPoll(); //issue at least one for the check below<br />if (USB_INTR_PENDING &amp; (1&lt;&lt;USB_INTR_PENDING_BIT)) // Usbpoll() collided with data packet<br />{<br />uint8_t ctr;<br /><br />// loop takes 5 cycles<br />asm volatile(<br />&quot; ldi %0,%1 \n\t&quot;<br />&quot;loop%=: sbis %2,%3 \n\t&quot;<br />&quot; ldi %0,%1 \n\t&quot;<br />&quot; subi %0,1 \n\t&quot;<br />&quot; brne loop%= \n\t&quot;<br />: &quot;=&amp;d&quot; (ctr)<br />: &quot;M&quot; ((uint8_t)(8.8f*(F_CPU/1.0e6f)/5.0f+0.5)), &quot;I&quot; (_SFR_IO_ADDR(USBIN)), &quot;M&quot; (USB_CFG_DMINUS_BIT)<br />);<br />USB_INTR_PENDING = 1&lt;&lt;USB_INTR_PENDING_BIT;<br />}<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Fri Nov 10, 2017 6:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2017-11-10T17:59:23+02:00</updated>

		<published>2017-11-10T17:59:23+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33267#p33267</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33267#p33267"/>
		<title type="html"><![CDATA[v-usb not really good for control transfers after all.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11102&amp;p=33267#p33267"><![CDATA[
If anyone has looked in to the v-usb on the wire you will learn a few things...<br /><br />sending the NACK consumes all the CPU time.and  this can go on for quite a while. The host only stops sending IN packets right before the end of the frame, to avoid colliding with the 1 ms keep alive pulse. This finally leaves enough time for V-USB to process the data and prepare the TX buffer. This is extremely wasteful, since less than 10% of the USB bus traffic is actively transferring data and almost 90% of the CPU time is spent on “appeasing” the host. In the worst case, only one valid transmission can be processed per frame (1 ms). Since a low-speed USB data packet carries a maximum of 8 bytes, this limits the theoretical throughput to 8000 bytes/s and much less in practice due to additional protocol overhead. Although extremely ugly, it does work for V-USB. <br /><br />this is not my original wording, complements to TIm for this. Though I see this is all very true.  This does work out well if you have nothing you intend to do with the chip in any depth. For example, try running 300 us of ASM time sensitive code (were you need to cli) It simply will not work.  If you try to place that ASM in the 1 ms window and not disable interrupts, the control transfer will run it over. Being they take seconds to complete, this likelihood goes way up. <br /><br /><strong class="text-strong">Breaching the limits of v-usb...</strong> So in-part with tims research I devises a method I think is going to work. <br /><br />pseudo code.<br /><br />main<br />{<br />.<br />.<br /><br />usbDisableAllRequests();//force NAK<br />EIMSK &amp;=  ~(1 &lt;&lt; INT0);//disable int<br />do_ASM_sensitive_Code<br />EIMSK |= (1 &lt;&lt; INT0); //enable int<br />usbEnableAllRequests();//free NAK  condition. <br />.<br />.<br />}<br /><br /><br />asmcommon.lst change needed<br />sofError:<br />    POP_RETI                    ;macro call<br />    SBIC EIMSK, 1 ;if not set branch (int0)<br />    RETI;was set<br />    RET;was not<br /><br /><br />Idea here is that you can tell the driver to return NAK. This is ok but not if interrupts are disabled. So we change reti to ret in the SOF and allow it to constantly send NAK if the int. is cleared. This change will not effect any v-usb operation. It is only done if you disable the interrupt (could change to accept other pins) and in this case, this is best. <br /><br /><br />This is a work in progress... Thoughts<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Fri Nov 10, 2017 5:59 pm</p><hr />
]]></content>
	</entry>
	</feed>
