2020-10-08 06:01 AM
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?
Solved! Go to Solution.
2020-10-13 06:15 AM
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
2020-10-08 07:11 AM
The L1 family has an integrated pullup.
2020-10-08 08:11 AM
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.
2020-10-08 10:30 AM
Just answering the question you asked in the title.
I would download an example to see if you can get that working:
2020-10-09 08:05 AM
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.
2020-10-13 06:15 AM
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
2020-10-14 10:24 PM
Thanks a lot. It's really works.