View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
There's any way to shut off USB? |
Posted: Fri Feb 03, 2017 11:19 am |
|
|
I need to put the device PIC18F67J50 in to low power mode, I already disabled all the interrupts but if I reconnect the USB in that state I get an error on windows which is ok because the USB hardware still active.
Can I disable by calling a function/routine or I must to do my own routine to shut off the USB port by changing bits like in assembler?
I'm using CDC CCS libraries. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Fri Feb 03, 2017 11:40 am |
|
|
Are you actually attached to the USB bus?.
If so, you have USB power available.
It's not actually legal to turn off the USB transceivers if you are attached, unless the _host_ says for you to enter low power mode.
So long as you use usb_init_cs, and have a connection sense (this is actually _required_ if the device has it's own power), you can disable the USB bus if the connection sense is low, and re-enable it when the CS line goes high again.
usb_set_configured(0);
Disables the endpoints. Then
usb_detach();
switches off the hardware. |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Fri Feb 03, 2017 3:10 pm |
|
|
Yes, the device is attached.
The whole idea is to give to the production center(assembling center, and test center) a way to program, configure and turn off the device, which have internal battery, so the device can be put in to the stock center with the battery connected and avoid that the device drain the internal battery as much as possible.
The device is a blackbox with LEDs, and have no buttons or switches.
That's why I need to turn off the device by USB.
So the device receive the order to shut off through CDC port and must to shutdown all, even the USB port itself. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Fri Feb 03, 2017 3:34 pm |
|
|
Problem is that Windows will intermittently see a device that it still attached, but has it's transceivers powered off, and may give an error:
"one of the USB device attached to this computer has malfunctioned, and Windows does not recognise it".
Why not just have the USB always power down when the connection sense goes low?. This way it'll always be off when disconnected. As soon as you haven't got USB power the USB will be turned off. |
|
|
|