cancel
Showing results for 
Search instead for 
Did you mean: 

How to use USB on STM32L1 series without external pull-up resistor?

JBlac.3
Associate II

I am using USB port on STM32L151RE MCU and I have to use external pull-up resistor on DP line. However, AN4879 document says that STM32L1 Series have embedded pull-up resistor on USB DP line. But DP pin doesn't pull-up automatically after USB initialization, like on STM32F4 or STM32L4 Series. I was trying on 151RE and 152RC MCU and nothing. Also, I was trying to pull-up this pin manually and I got 3V on DP line, but the voltage drops to 1V if plug USB connector and device didn't recognize. In errata sheet on STM32L15xxE there isn't any information about that problem. What's wrong with pull-up PD line? Is anybody use usb in 151 MCU?

1 ACCEPTED SOLUTION

Accepted Solutions
Lubos KOUDELKA
ST Employee

Hello,

unlike to other STM32 families with integrated pull-up resistor in USB, pull-up in STM32L152 is not controlled by USB peripheral(registers), but by SYSCFG. In reference manual you can find bit USB_PU in SYSCFG_PMC register.

In STM32CubeMX repository example I can see defines, which control pull-up. Please use in your project if missing:

#define __HAL_SYSCFG_USBPULLUP_ENABLE()    SET_BIT(SYSCFG->PMC, SYSCFG_PMC_USB_PU)

#define __HAL_SYSCFG_USBPULLUP_DISABLE()   CLEAR_BIT(SYSCFG->PMC, SYSCFG_PMC_USB_PU)

Best regards,

Lubos

View solution in original post

6 REPLIES 6
TDK
Guru

The L1 family has an integrated pullup.

https://www.st.com/resource/en/application_note/dm00296349-usb-hardware-and-pcb-guidelines-using-stm32-mcus-stmicroelectronics.pdf

If you feel a post has answered your question, please click "Accept as Solution".
JBlac.3
Associate II

Yes, I read it. I pointed to this doc in my question. But I don't understand why it doesn't work properly. I have tried the same test program on different mcu, like F4, L4 and L1 series, but it doesn't work on L1 series. I use CubeMX to turn on USB port, but in L1 series it doesn't work without external pull-up resistor.

TDK
Guru

Just answering the question you asked in the title.

I would download an example to see if you can get that working:

https://github.com/STMicroelectronics/STM32CubeL1/tree/master/Projects/STM32L152D-EVAL/Applications/USB_Device

If you feel a post has answered your question, please click "Accept as Solution".

Sorry, I have changed the title.

I've downloaded these examples and upload HID example on my STM32L152 Discovery board. And nothing. USB doesn't work without external pull-up.

Lubos KOUDELKA
ST Employee

Hello,

unlike to other STM32 families with integrated pull-up resistor in USB, pull-up in STM32L152 is not controlled by USB peripheral(registers), but by SYSCFG. In reference manual you can find bit USB_PU in SYSCFG_PMC register.

In STM32CubeMX repository example I can see defines, which control pull-up. Please use in your project if missing:

#define __HAL_SYSCFG_USBPULLUP_ENABLE()    SET_BIT(SYSCFG->PMC, SYSCFG_PMC_USB_PU)

#define __HAL_SYSCFG_USBPULLUP_DISABLE()   CLEAR_BIT(SYSCFG->PMC, SYSCFG_PMC_USB_PU)

Best regards,

Lubos

Thanks a lot. It's really works.