Electronic – Wake-up PC from sleep mode using PIC24FJ256GB106

pic

I am trying to wake-up the PC from sleep mode, using PIC24FJ256GB106.

I am using Windows 7. I have installed "Microchip Solutions v2012-04-03" and I used the firmware from "Device – HID – Custom Demos" directory as a starting point.

When I connect my USB device, it shows up in Device Manager, in "Human Interface Devices" tree. (I am using Windows 7) But there is no "Power Management" tab from which I can check the "Allow this device to wake the computer".

Anyways, I figured out some kind of a solution for my device to wake up the computer from sleep. So I have to:

  • connect a USB mouse on the same root hub with the device

  • I have to check the "Allow this device to wake up the computer" for the mouse

  • and in the USBCBSendResume() function, I had to remove the if(USBGetRemoteWakeupStatus() == TRUE) condition

How can I wake-up the PC only using the device, without the mouse connected on the same root hub?

Best Answer

You will need to alter the config descriptor to enable the device to wake the PC from sleep. Specifically this means setting bit 5 in the bmAttributes byte. Have a look through the Microchip USB stack (e.g. config_desc.c or whatever it's named currently), there are plenty of comments to guide you.

Config Descriptor

wTotalLengthequals the number of bytes in the configuration descriptor and all of its subordinate descriptors.
bNumInterfacesequals the number of interfaces in the configuration. The minimum is 01h.
bConfigurationValue identifies the configuration for Get Configuration and Set Configuration requests and must be 01h or higher. A Set Configuration request with a value of zero causes the device to enter the Not Configured state.
iConfiguration is an index to a string that describes the configuration. This value is zero if there is no string descriptor.
bmAttributes sets bit 6 = 1 if the device is self-powered and zero if bus pow-ered. Bit 5 = 1 if the device supports the remote wakeup feature, which enables a suspended USB device to tell the host that the device wants to communicate. The other bits in the field are unused. Bits 4..0 must be zero. Bit 7 must equal 1 for compatibility with USB 1.0
bMaxPower.Specifies how much bus current a device requires. For USB 2.0, bMaxPower is in units of 2 mA. If the device requires 200 mA, bMax-Power=64h. For SuperSpeed, bMaxPower is in units of 8 mA.

Above table and info from "USB Complete" by Jan Axelson - an excellent book on all things USB.