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 CCS Technical Support

USB Power - Request more current

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



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

USB Power - Request more current
PostPosted: Wed Aug 03, 2011 8:50 am     Reply with quote

Been looking over some articles about USB 2.0 and found that a host will supply 500mA of current to connected devices. It also says that this current may be requested by a "high-power" device. Is this something I must do within my PIC code or is this automatically handled in the CCS USB library/driver somehow? Using the PIC18F26J50.

Thanks,

Matt
_________________
-Matt
Ttelmah



Joined: 11 Mar 2010
Posts: 19477

View user's profile Send private message

PostPosted: Wed Aug 03, 2011 9:13 am     Reply with quote

In the descriptor files. Look for the setting 'USB_CONFIG_BUS_POWER'. Default is 100 (100mA). You can set it yourself to a higher value _before_ loading the descriptor, and this higher value will be used.
Beware of relying on too much power here though. Though USB should be able to deliver 500mA, if (for instance), you attach via an unpowered hub, the 500mA, is the maximum _total_ for all devices attached to this hub, and the hub itself.

Best Wishes
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

Thanks
PostPosted: Wed Aug 03, 2011 12:51 pm     Reply with quote

Thanks. Is there a way to tell if the request was made successfully? I think I seen a snoopy program on one of the forum posts.

-Matt
_________________
-Matt
Ttelmah



Joined: 11 Mar 2010
Posts: 19477

View user's profile Send private message

PostPosted: Thu Aug 04, 2011 10:37 am     Reply with quote

Not really.
Problem is that power management is only 'partial'. The ports normally have something akin to a self resetting fuse, limiting the current to 500mA, but nothing to limit the current below this. So a lot of devices will just attach, and take what they need, without 'telling' the host this. This is how you can have USB charging cables that are not seen as USB devices at all. Further, many hubs have less power available than they require (so you have multi port USB hubs, with - say - a 1A supply). As far as the host is concerned they can deliver the power, but if all the attached devices actually drew 500mA, the supply would probably shut down..... In this latter case, it would be seen, since the devices already attached would suddenly disconnect. Generally, if the enumeration is successful, and your supply voltage is stable and perhaps >4.5v, then the power is there.
On 'well behaved' setups, say the port on a laptop, with good power management, the OS will normally put up an error box reporting that the power was not available, if a device requests more current than the unit can supply.

Best Wishes
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