10 years, 5 months ago.

Switching USB host power on and off

I have a simple USB LED plugged into the app board's host port and I would like to switch it on and off programatically.

I have looked at the USBHost driver and found lines which happen to do exactly this when driver is initialised.

So I wrote this:

switch( usb_led_power ) {
        case 0: LPC_SC->PCONP &= ~(1UL<<31); break;
        case 1: LPC_SC->PCONP |= (1UL<<31); break;
}

The code compiles and doesn't crash, however the USB devices receives supply voltage continuously. I have also checked the datasheet for LPC1768 and the bitmask looks correct.

1 Answer

10 years, 5 months ago.

I think that powers up/powers down the USB peripheral on the microcontroller. You want to cut off the power the USB LED receives, however as you can see in the schematic: http://mbed.org/media/uploads/chris/mbed-014.1_b.pdf, the power lines are hardwired.

And your simple USB LED probably is always on as long as there is USB power.

Accepted Answer