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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2014-01-21T11:15:14+02:00</updated>

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

		<entry>
		<author><name><![CDATA[stf92]]></name></author>
		<updated>2014-01-21T11:15:14+02:00</updated>

		<published>2014-01-21T11:15:14+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26483#p26483</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26483#p26483"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26483#p26483"><![CDATA[
Well then next time I'll include a link to the sources Im working with. There is no DeviceDisconnect, DeviceConnect functions in them. Anyway, my concern was with respect to the thread title, and I now see I was the victim of a blunder (made by me). Now I see that the host interrupts the device (activates the INT0 pin) each SYNC. I'd forgotten the interrupts are set to edge triggered, positive edge. It is the first K in the SYNC that triggers the interrupts if unmasked and global enabled. This changes everything in my perspective. <br /><br />By this time I'm busy with the usb_control_msg() function of libusb (linux). I see its parameters nearly match the ones in table 9-2 of USB specications 1.1 and 2.0, which by now I know well, with the exception of... What a pity! The bmRequestType is 0xC0, with the result that the type is type=vendor, and  those specifications only cover standard device requests!<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20156">stf92</a> — Tue Jan 21, 2014 11:15 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[cpldcpu]]></name></author>
		<updated>2014-01-21T09:53:34+02:00</updated>

		<published>2014-01-21T09:53:34+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26482#p26482</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26482#p26482"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26482#p26482"><![CDATA[
The debounce interval is covered by the code is posted up here: <!-- l --><a class="postlink-local" href="http://forums.obdev.at/viewtopic.php?f=8&amp;t=8801&amp;sid=166e80c1207f99a9e917f28d23023b3e#p26452">viewtopic.php?f=8&amp;t=8801&amp;sid=166e80c1207f99a9e917f28d23023b3e#p26452</a><!-- l --><br /><br />It is not necessary to take care of debouncing in the reset code. The code does exactly what I mentioned.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20062">cpldcpu</a> — Tue Jan 21, 2014 9:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stf92]]></name></author>
		<updated>2014-01-20T00:44:23+02:00</updated>

		<published>2014-01-20T00:44:23+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26471#p26471</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26471#p26471"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26471#p26471"><![CDATA[
Yes, there is no bouncing in the oscillographs. I got distracted. I was speaking about the time when the device is plugged into the hub jack: <div class="codebox"><p>Code: </p><pre><code>deltat3: (TATTDB) This is a debounce interval with a minimum duration of 100ms that is provided by the USB<br />System Software. It ensures that the electrical and mechanical connection is stable before software<br />attempts to reset the attached device. The interval starts when the USB System Software is notified<br />of a connection detection. The interval restarts if there is a disconnect. The debounce interval<br />ensures that power is stable at the device for at least 100ms before any requests will be sent to the<br />device.<br /></code></pre></div><br />From the text explaining the figure in post #1, in the USB 1.1 specification.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20156">stf92</a> — Mon Jan 20, 2014 12:44 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[blargg]]></name></author>
		<updated>2014-01-19T08:24:18+02:00</updated>

		<published>2014-01-19T08:24:18+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26465#p26465</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26465#p26465"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26465#p26465"><![CDATA[
There shouldn't be any bouncing, as that's an artifact of mechanical switches. You may be thinking of ringing, but that's much more mild than switch bounce, and shouldn't get near logic thresholds so shouldn't affect the digital data. As I understand it, usbPoll() detects reset by one of the USB lines being in a non-idle state for an extended period of time. This condition is present for quite a while, so usbPoll() might notice it more than once before it ends. Thus, to avoid calling the user's reset hook more than once, it keeps track of whether it's already called it. The reason for usbPoll() having a loop that checks multiple times is that it needs to distinguish the line being active continuously, and it happening to catch it active during normal data transmission. In the latter, it toggles constantly between the active and idle states (which is the solid white parts you see in the image; if zoomed in you'd see lots of signal edges close together).<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20076">blargg</a> — Sun Jan 19, 2014 8:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stf92]]></name></author>
		<updated>2014-01-19T04:27:21+02:00</updated>

		<published>2014-01-19T04:27:21+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26460#p26460</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26460#p26460"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26460#p26460"><![CDATA[
<blockquote><div><cite>cpldcpu wrote:</cite>Maybe the image below helps. It shows the USB traffic during device enumeration. &quot;Int active&quot; is high while the interrupt routine is executed, tx during set.<br /><br />If you want to understand the usb protocol, i would recommend you get a logic analyzer with USB protocol support. The saleae support USB1.1 in it's newset beta.<br /></div></blockquote><br />It helps, thank you. <blockquote class="uncited"><div>Regarding external hardware: You could try to implement the bitstuffing and xor decoding in a small CPLD or even discrete logic. The you could use a UART or SPI to read the USB traffic which would unload the CPU a lot.</div></blockquote><br />UART: great idea!<br /><blockquote class="uncited"><div>I am not sure why you are looking at an old version of the driver? The strange reset code is only there to make sure that the reset hook is not called multiple times during a reset, even if usbpoll() is called more than once.</div></blockquote><br />That's precisely what debouncing is about. You can see bouncing at the end of the reset pulse in your oscilloscope (or logic analyzer, which one?) diagrams. As to version age, the more primitive the program the easiest its analysis. Above all, I'm trying learn.<br />[/quote]<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20156">stf92</a> — Sun Jan 19, 2014 4:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[cpldcpu]]></name></author>
		<updated>2014-01-18T12:43:17+02:00</updated>

		<published>2014-01-18T12:43:17+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26456#p26456</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26456#p26456"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26456#p26456"><![CDATA[
Maybe the image below helps. It shows the USB traffic during device enumeration. &quot;Int active&quot; is high while the interrupt routine is executed, tx during set.<br /><br />If you want to understand the usb protocol, i would recommend you get a logic analyzer with USB protocol support. The saleae support USB1.1 in it's newset beta.<br /><br />Regarding external hardware: You could try to implement the bitstuffing and xor decoding in a small CPLD or even discrete logic. The you could use a UART or SPI to read the USB traffic which would unload the CPU a lot.<br /><br />I am not sure why you are looking at an old version of the driver? The strange reset code is only there to make sure that the reset hook is not called multiple times during a reset, even if usbpoll() is called more than once.<br /><br /><a href="http://imgur.com/3Gmgbv6" class="postlink"><img src="http://i.imgur.com/3Gmgbv6.png" class="postimage" alt="Image" /></a><br /><br />edit: man this forum really does not like images.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20062">cpldcpu</a> — Sat Jan 18, 2014 12:43 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stf92]]></name></author>
		<updated>2014-01-18T12:23:51+02:00</updated>

		<published>2014-01-18T12:23:51+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26455#p26455</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26455#p26455"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26455#p26455"><![CDATA[
Well, it's really a pure theoretical question, but with a view to implement the data adquisition part of the program in hardware: bit reading and stuffing. This would let slow or old fashioned microprocessors to interface USB. My knowledge of USB started with the study of this program, which has led to understand the basics of the USB 1.1 specification. But now I see I would need at least 11 * 8 = 88-bit shift registers which kind of forces to use FPGA, and FPGA seems not to be do-it-your-self stuff. Now I see that, taking into account the high clock rates and large memory space of modern microcontrollers, a 2K software controller like the one object of this subforum is feasible (Christian's program of 2004 is 2KB long). <br /><br />On the other hand, the Circuit Cellar project is up and running. It is just a MAX517 used as a programmable power source, programmble form a PC via USB and is up and running, save that I dispensed with the MAX517 and have a 33-ICs Z80 system reading the data sent by the device (all of them TTL small scale integration save RAM, ROM and CPU). <br /><br />Anyways, useless as it is that knowledge in a ready-to-use world, I am quickly advancing in the comprehension of Christian's driver. To really understand it, I would need to make a state diagram of the program. And for this, a precise knowing of timing, fundamentally idle time between packages and the reset thing, is imperative. <br /><br />The application program, main function is:<div class="codebox"><p>Code: </p><pre><code>int main(void)<br />{ <br />  DDRB = 0x22;   // 0010 0010 PB1=SDA and PB5=SCL are output<br />  PORTB = 0x22;   //SDA=SCL=1<br /><br />  usbInit();<br />  sei();<br />  for(;;){      // main event loop<br />       usbPoll();<br />     }<br />  return 0;<br />}</code></pre></div><br />As you know, usbInit() unmasks INT0 interrupts ans sei() enables interrupts globally. When power is applied, let it be time t0,  the ATtiny85 uC @12MHz is quickly running ready to accept interruptions. Whereas the host will spend in the order of hundreds of ms, counting from t0, to issue the reset signal. So I think usbPoll() will have a very pretty choice of executing all through before the interrupt service routine is entered. But that is not all. In usbdrv.c (2004 version, 12MHz clock), we have: <div class="codebox"><p>Code: </p><pre><code>static inline uchar   isNotSE0(void)<br />{<br />uchar   rval;<br />/* We want to do<br /> *     return (USBIN &amp; USBMASK);<br /> * here, but the compiler does int-expansion acrobatics.<br /> * We can avoid this by assigning to a char-sized variable.<br /> */<br />   rval = USBIN &amp; USBMASK;<br />   return rval;<br />}</code></pre></div><br /><br />and, in its usbPoll function:<div class="codebox"><p>Code: </p><pre><code>if(isNotSE0()){ /* SE0 state */<br />                usbIsReset = 0;<br />        }else{<br />                /* check whether SE0 lasts for more than 2.5us (3.75 bit times) <br />                if(!usbIsReset){<br />                        uchar i;<br />                        for(i=100;i;i--){<br />                                if(isNotSE0())<br />                                        goto notUsbReset;<br />                        }<br />                        usbIsReset = 1;<br />                        usbDeviceId = 0;<br />                        usbNewDeviceId = 0;<br />notUsbReset:;<br />                }<br />        }<br /><br /></code></pre></div><br />This code makes shure to debounce the reset signal after attach and usbDeviceId and usbNewDeviceId get zeroed before entering the ISR, though as we discussed and another thread, their values are zero at this time as a result of the BBS section been zero at runtime. Does this line of reasoning seem plausible?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20156">stf92</a> — Sat Jan 18, 2014 12:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[cpldcpu]]></name></author>
		<updated>2014-01-18T06:53:58+02:00</updated>

		<published>2014-01-18T06:53:58+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26452#p26452</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26452#p26452"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26452#p26452"><![CDATA[
It can be a good idea to simulate a device disconnect after program start to force a bus reset. This removes all ambiguity after startup.<br /><br /><div class="codebox"><p>Code: </p><pre><code> usbDeviceDisconnect();  /* do this while interrupts are disabled */<br /> _delay_ms(500);  <br />  usbDeviceConnect();<br /></code></pre></div><br /><br />Otherwise you should be more clear about what you actually want to accomplish with your code. Is there an actual issue or is this a general question?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20062">cpldcpu</a> — Sat Jan 18, 2014 6:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stf92]]></name></author>
		<updated>2014-01-15T12:03:07+02:00</updated>

		<published>2014-01-15T12:03:07+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26436#p26436</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26436#p26436"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26436#p26436"><![CDATA[
<blockquote><div><cite>cpldcpu wrote:</cite>Can the Attiny 85 do 12 MHz at 3.3V? I am certain this is out of spec.</div></blockquote><br />This is Yoshiyasu Takefuji's project, published in Circuit Cellar in issue no.213, year 2008, using Christian's driver. He arrived at the point (12MHz, 3.3V) by interpolation, I think. Anyway, I would like to draw attention towards the timing matter that I mentioned. <blockquote class="uncited"><div>If you clear pending interrupts before the SEI there may be. Otherwise the is most likely an interrupt pending and the ISR is called. You should mention what you are doing before the SEI.</div></blockquote><br />The device has just been plugged into the host port. What I do before the sei() is exactly depicted in the code block of post #1, which is ALL of the main function. I think you know what usbInit() does, do you?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20156">stf92</a> — Wed Jan 15, 2014 12:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[cpldcpu]]></name></author>
		<updated>2014-01-14T19:25:17+02:00</updated>

		<published>2014-01-14T19:25:17+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26430#p26430</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26430#p26430"/>
		<title type="html"><![CDATA[Re: Does usbPoll() get executed before entry to the ISR?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8801&amp;p=26430#p26430"><![CDATA[
&gt;it uses the USB 5V and a low threshold 3.3V regulator <br /><br />Can the Attiny 85 do 12 MHz at 3.3V? I am certain this is out of spec.<br /><br />&gt; is there enough time for usbPoll() to complete execution for the first time before control goes to the ISR?<br /><br />If you clear pending interrupts before the SEI there may be. Otherwise the is most likely an interrupt pending and the ISR is called. You should mention what you are doing before the SEI.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20062">cpldcpu</a> — Tue Jan 14, 2014 7:25 pm</p><hr />
]]></content>
	</entry>
	</feed>
