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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2010-01-07T12:22:30+02:00</updated>

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

		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2010-01-07T12:22:30+02:00</updated>

		<published>2010-01-07T12:22:30+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3716&amp;p=12757#p12757</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3716&amp;p=12757#p12757"/>
		<title type="html"><![CDATA[Re: Powersaving USB device]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3716&amp;p=12757#p12757"><![CDATA[
I have a low power USB design which uses the following tricks to reduce battery consumption:<br />(1) The design uses a 32 kHz crystal and synchronizes the RC oscillator to it.<br />(2) When USB is connected, the main clock frequency is synchronized to 12.8 MHz, without USB, we use 1 MHz.<br />(3) Every 1 s interval we poll for USB connectivity:<br /><div class="codebox"><p>Code: </p><pre><code>static void usbModeEnter(void)<br />{<br />static const prog_char usbText&#91;16&#93; =    &quot;  USB   &quot;<br />                                        &quot;  MODE  &quot;;<br />    powerWasOn = powerIsOn;<br />    if(!powerIsOn)<br />        powerOn();<br />    logSetRunning(0);<br />    powerRegulatorOff();                // ensure that voltage regulator is not operated at 12 Mhz<br />    usbDeviceDisconnect();<br />    dispFillConst(usbText);<br />    displaySendContent(displayRam&#91;0&#93;);<br />    _delay_ms(200);<br />    usbStoredOsccal = OSCCAL;<br />    OSCCAL = usbOsccal;<br />    clock_prescale_set(clock_div_1);    // turbo boost...<br />    usbInit();<br />    isUsbMode = 1;<br />    usbDeviceConnect();<br />}<br /><br />static void usbModeLeave(void)<br />{<br />    USB_INTR_ENABLE &amp;= ~M1(USB_INTR_ENABLE_BIT);<br />    clock_prescale_set(clock_div_8);    // back to normal speed<br />    usbOsccal = OSCCAL;<br />    OSCCAL = usbStoredOsccal;<br />    PORT_DDR_SET(PIN_USB_DMINUS);<br />    PORT_DDR_SET(PIN_USB_DPLUS);<br />    isUsbMode = 0;<br />    needUpdate = 1;<br />    powerRegulatorOn();<br />    if(!powerWasOn)<br />        powerOff();<br />    fifoFlush();<br />}<br /><br />static void pollUsbMode(void)<br />{<br />    if(isUsbMode){<br />        uchar i;<br />        for(i = 0; i &lt; 3; i++){<br />            uchar x = PORT_IN(PIN_USB_DMINUS);<br />            x &amp;= M1(PORT_BIT(PIN_USB_DPLUS)) | M1(PORT_BIT(PIN_USB_DMINUS));<br />            if(x == M1(PORT_BIT(PIN_USB_DMINUS)))   // valid USB idle mode<br />                return;<br />        }<br />        // if we did not detect valid USB idle status 3 times in a row, leave USB mode<br />        usbModeLeave();<br />    }else{<br />        PORT_DDR_CLR(PIN_USB_DMINUS);<br />        _delay_us(5);<br />        if(PORT_PIN_VALUE(PIN_USB_DMINUS)){ // if we have a pull-up<br />            usbModeEnter();<br />        }else{<br />            PORT_DDR_SET(PIN_USB_DMINUS);<br />        }<br />    }<br />}<br /></code></pre></div><br />(4) The supply voltage is reduced to the battery voltage when possible. Otherwise we use a step-up converter.<br /><br />The USB connectivity check works by sampling D-. Since the 1k5 pull-up is connected to USB supply, D- is low without USB connection. You must decouple the USB supply with a diode, though, so that the battery can't power the pull-up.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Thu Jan 07, 2010 12:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[qdot]]></name></author>
		<updated>2010-01-01T22:52:44+02:00</updated>

		<published>2010-01-01T22:52:44+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3716&amp;p=12675#p12675</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3716&amp;p=12675#p12675"/>
		<title type="html"><![CDATA[Powersaving USB device]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3716&amp;p=12675#p12675"><![CDATA[
Do you guys have any suggestions how to optimize power consumption of a device while it's not connected (and thus not charging) from the USB bus?<br /><br />I'm running out of IO ports, so I'm thinking 1M pullup on D+, and? how can I tell from inside the main poll loop if we're connected to the USB master and should never enter sleep states above 'idle' (otherwise interrupt wakeup will take more than 25 cycles <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" />), and when we're on battery and should be going as low as power down?<br /><br />Device: attiny84, external 16MHz oscillator.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=3323">qdot</a> — Fri Jan 01, 2010 10:52 pm</p><hr />
]]></content>
	</entry>
	</feed>
