Microchip USB Firmware - Modifying Power Limits PDF Print E-mail
Written by Mat   
Tuesday, 14 March 2006

This is a short article about how to modify the Microchip USB firmware used in the Basic USB Firmware article to allow the pic to draw more current than the 100mA limit imposed by the PC.

Please note all code is released AS-IS and should used at the users own risk, no guarantee is made by PICcoder.co.uk or the author with regards to the accuracy of the diagrams or code contained in this article.

Discuss this article on the forums. (5 posts)

 

Having spent quite a while trying to figure out why windows was suddenly booting my PIC from the USB, it eventually became clear that I was drawing too much current from the USB and the PC therefore had decided to take the appropiate action of removing my device for me.

Looking into the problem further, it becomes appart why, and the fix is surprisingly easy! When the PIC is connected to the PC, it goes through a process called enumeration which is essentially a method by which the PIC identifies itself to the PC, and informs it of properties and functions the PIC can perform.

One of the pieces of information transmitted to the PC is the power requirements for the PIC, this is set by default to 100mA. This limit can be found by looking in 'Device Manager' whilst the PIC is connected to the PC (and the drivers are installed!). If you goto the section labelled 'Universal Serial Bus controllers', and expand this you will find several 'USB Root Hub'  devices. You now need to locate the specific hub the PIC is connect to, this can be done by clicking properties on each 'USB Root Hub' and then selecting the 'Power' tab. Hopefully one of these hubs should contain your PIC18F4550 device, and next to it you should find the power required by the device, which is specified by the enumeration process. An example of this can be seen below, showing the power required limited to 100mA.

100mA Limit
100mA Limit

 In my case I was drawing slightly more than this, so PC kept disconnecting the device, however this can be fixed by a simple software change in the PIC code. If you open usbdsc.c and find line 209, shown below, the value can be adjusted to set the requied power.The max power consumption (in mA) is equal to this number times two, and therefore 100 would represent 200mA.
 

USB Power requirements
USB Power requirements
  

 The maximum power which can typically be drawn from a USB port is 500mA, therefore do not exceed this, and limit the number below 250.This code worked on my system, however I cannot garentee it will work on yours, so use at your own risk!

Finally an example of the increased power requirments, with the modified pic code running (using 250 in usbdsc.c).

 

500mA Power Requirement
500mA Power Requirement

Hope this is of some use to you, as it certainly got me out of a problem! Please bear in mind though this isnt fully tested and if you drawn too much current through the USB you could do internal damage to the PC, if it does not disconnect the device correctly!

Mat Clayton 

Discuss this article on the forums. (5 posts)

Last Updated ( Monday, 19 June 2006 )
 
< Prev   Next >