CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

There's any way to shut off USB?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

There's any way to shut off USB?
PostPosted: Fri Feb 03, 2017 11:19 am     Reply with quote

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: 19436

View user's profile Send private message

PostPosted: Fri Feb 03, 2017 11:40 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Feb 03, 2017 3:10 pm     Reply with quote

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: 19436

View user's profile Send private message

PostPosted: Fri Feb 03, 2017 3:34 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group