Page 1 of 1

Shut down or sleep mode for AVR-USB

Posted: Tue Apr 08, 2008 8:49 am
by Stephen
I have completed a device that with many LEDs. I have tried it on Windows XP in several desktop computers and notebook computers. Some computer's motherboard design will cut off the 5V power from USB port, some will not.

My problem: After shut down of computer. My device's LED are still getting ON, the AVR MCU is still running and It remains the last state of computer shut down. What approach that i can solve this problem? Have any loop subroutine that can detect the computer was off? Thanks.

Posted: Tue Apr 08, 2008 9:35 am
by Guest
You could detect if there's a 1kHz idle clock on the D+ line. If it's gone the PC is off.

Tom

Posted: Thu Apr 10, 2008 11:43 am
by christian
See the end of http://avrusb.wikidot.com/examples, the section about suspend mode. This explains how suspend mode can be implemented.

Posted: Mon Apr 14, 2008 8:58 am
by Stephen
hi, thanks for both you guy's reply.

Now, my design's D+ pin is connected to INT0
Do i have to re-layout to D- pin to INT0 or modification of firmware (keep D+ pin to INTO)can solve this issue? Thanks.

I want to study more information about this 1kHz idle clock, what documents that i can check about it. I want to know whether the idle clock is still exists when Windows at sleep mode. Thanks.

christian wrote:See the end of http://avrusb.wikidot.com/examples, the section about suspend mode. This explains how suspend mode can be implemented.

Posted: Mon Apr 14, 2008 9:42 am
by christian
If D- is wired to a pin which can trigger an interrupt (e.g. INT1, pin change interrupt), there's also an example available how to implement it.

Suspend mode is documented in the USB specification. When the host goes to sleep it MUST stop sending the 1 kHz pulses. The device may wake up the host by sending an SE0 (= USB Reset = very short disconnect) signal.

Posted: Mon Apr 14, 2008 9:57 am
by Stephen
hi, I was confused. Tom said D+ has also got this 1kHz pulse. Any reason that why i can't utilized this 1kHz pulse from D+. The D- pin in my layout is not connected to any interrupt. Thanks.

Posted: Mon Apr 14, 2008 10:43 am
by christian
The 1kHz SE0 pulses are on D-, not D+. You therefore need an interrupt on D-.

Posted: Tue Apr 15, 2008 8:27 am
by Stephen
hi, sorry for too much questions since it is too much documents about USB.

I read the document "USB in a Nutshell" from beyondlogic. In page 5 "Electrical", it state "Certain bus states are indicated by single ended signals on D+, D- or both." It seems no more information i can dig into in this documents.

Christian replied: "The device may wake up the host by sending an SE0 (= USB Reset = very short disconnect) signal." <- My device doesn't need to wake up the host. It just need to know host is sleep/OFF, then device go into suspend mode. In this case, can i use D+?

Thanks.

christian wrote:The 1kHz SE0 pulses are on D-, not D+. You therefore need an interrupt on D-.

Posted: Tue Apr 15, 2008 10:06 am
by christian
You need to detect the Start Of Frame pulses. Since they are on D-, you need to supervise D-. The pulses are short (667 ns) and rare (every 1 ms), so you need hardware to detect them. This hardware could be an interrupt or a counter input.

There are no such pulses on D+ (therefore we use D+ for the USB interrupt so that no unnecessary interrupts are generated).

The USB spec defines this in an abstract language because signal lines are swapped between low speed and full speed devices.