Skip to main content
JBlac.3
Associate
October 8, 2020
Solved

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

  • October 8, 2020
  • 6 replies
  • 2876 views

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?

This topic has been closed for replies.
Best answer by Lubos KOUDELKA

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

6 replies

TDK
October 8, 2020
"If you feel a post has answered your question, please click ""Accept as Solution""."
JBlac.3
JBlac.3Author
Associate
October 8, 2020

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
October 8, 2020

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""."
JBlac.3
JBlac.3Author
Associate
October 9, 2020

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
Lubos KOUDELKABest answer
ST Employee
October 13, 2020

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

JBlac.3
JBlac.3Author
Associate
October 15, 2020

Thanks a lot. It's really works.