Shut down or sleep mode for AVR-USB

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Stephen
Posts: 6
Joined: Mon Apr 07, 2008 7:20 am

Shut down or sleep mode for AVR-USB

Post by Stephen » Tue Apr 08, 2008 8:49 am

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.

Guest

Post by Guest » Tue Apr 08, 2008 9:35 am

You could detect if there's a 1kHz idle clock on the D+ line. If it's gone the PC is off.

Tom

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Apr 10, 2008 11:43 am

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

Stephen
Posts: 6
Joined: Mon Apr 07, 2008 7:20 am

Post by Stephen » Mon Apr 14, 2008 8:58 am

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.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Mon Apr 14, 2008 9:42 am

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.

Stephen
Posts: 6
Joined: Mon Apr 07, 2008 7:20 am

Post by Stephen » Mon Apr 14, 2008 9:57 am

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.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Mon Apr 14, 2008 10:43 am

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

Stephen
Posts: 6
Joined: Mon Apr 07, 2008 7:20 am

Post by Stephen » Tue Apr 15, 2008 8:27 am

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-.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Tue Apr 15, 2008 10:06 am

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.

Post Reply