cancel
Showing results for 
Search instead for 
Did you mean: 

Self Powered USB / VBUS / ST HAL / VCP STM32L151 how to activate

darkmaterial
Associate II

Can anyone tell me how to activate (which function must I run) the USB if I detect a VBUS on my EXTI Interrupt.

My STM32L151 is externally Powered. I activated the SELF_POWERED function in CUBEMX.

I monitor the VBUS on an external Interrupt (rising edge). If the interrupt fires I want to activate USB. BUT I dont know how 😁. MX_USB_DEVICE_Init(); Seems to be already called by CUBEMX in the initialization. Which functions do I need to call? What functions do I need to STOP USB?

Thank You

1 REPLY 1
Muhammed Güler
Senior II

You really don't need to do much. The STM32L1 series has an internal pullup resistor. Simply install the USB VCP as if it were powered by external power.

It would be better to put a protection element like USBLC6-2SC6 on the data line. If you plan to connect with the TYPE-C connector, you also need to connect 5K pulldown resistors to the CC pins.